Repository navigation
Add GCS blob store support via S3-compatible XML API with OAuth2 auth - #12975
Conversation
0c6864f to
a4566a3
Compare
|
@saintstack could I get your review on this PR as a follow up to the refactor PR? |
There was a problem hiding this comment.
Pull request overview
Adds Google Cloud Storage (GCS) support to the blobstore backup stack by reusing the S3-compatible XML API, while swapping SigV4 auth for OAuth2 Bearer token handling and extending URL parsing/test scaffolding.
Changes:
- Introduces
GCSBlobStoreEndpoint(inherits S3 operations, overrides auth/credential handling, bucket creation behavior). - Extends
IBlobStoreEndpoint::fromStringand knob help text to supportprovider=gcs(p=gcs) andgcspidparsing/round-tripping. - Adds GCS fixtures and test paths, including a new
gcs_client_testctest target running the existing S3 client integration suite against MockS3Server in “GCS mode”.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| fdbclient/tests/tests_common.sh | Adds provider detection and GCS branch in shared blobstore test environment setup. |
| fdbclient/tests/s3client_test.sh | Adds USE_MOCK_GCS execution path to reuse integration tests with GCS-style URLs/credentials. |
| fdbclient/tests/gcp_fixture.sh | New helper fixture for creating GCS test scratch dirs and credential JSON. |
| fdbclient/include/fdbclient/IBlobStore.h | Updates URL parameter help text to mention provider/p for selecting GCS. |
| fdbclient/include/fdbclient/GCSBlobStore.h | Declares GCSBlobStoreEndpoint and provider-specific overrides. |
| fdbclient/GCSBlobStore.cpp | Implements GCS auth/credential extraction, URL serialization tweaks, and unit tests. |
| fdbclient/CMakeLists.txt | Adds gcs_client_test ctest entry to run integration tests in mock GCS mode. |
| fdbclient/BlobStoreCommon.cpp | Extends blobstore URL parsing to construct GCSBlobStoreEndpoint when provider=gcs. |
| fdbbackup/tests/backup_tests_common.sh | Integrates provider detection into backup test environment setup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| Future<Void> updateSecret() override; | ||
| bool extractCredentialFields(JSONDoc& account) override; | ||
|
|
There was a problem hiding this comment.
GCSBlobStoreEndpoint inherits S3BlobStoreEndpoint::lookupSecretOnEachRequest(), which returns false when S3 creds aren’t being looked up. That prevents connect() from calling updateSecret(), so the OAuth2 token will never be refreshed from credential files (breaking the primary auth flow described in the PR). Override lookupSecretOnEachRequest() in this class (or add a lookupToken flag similar to S3’s lookupKey/lookupSecret) so credential-file token refresh actually runs.
| // GCS tokens may need to be refreshed from credential files on each request, even when | |
| // S3-style access-key/secret lookup is not enabled in the base class. | |
| bool lookupSecretOnEachRequest() const override { return true; } |
There was a problem hiding this comment.
I added the lookup token flag similar to S3's as per the second half of this comment
| std::string GCSBlobStoreEndpoint::getResourceURL(std::string resource, std::string params) const { | ||
| if (!params.empty()) | ||
| params.append("&"); | ||
| params.append("p=gcs"); | ||
| if (!projectId.empty()) { | ||
| params.append("&gcspid=").append(projectId); | ||
| } | ||
| return S3BlobStoreEndpoint::getResourceURL(resource, params); | ||
| } |
There was a problem hiding this comment.
getResourceURL() currently serializes as blobstore://@host/... (no token), even if the endpoint was created from a URL containing an inline bearer token. This breaks URL round-tripping for callers that don’t rely on credential files (e.g. backup list/listContainers returns URLs that won’t authenticate when reused). Consider including the token in the serialized URL when it was provided inline (and omit it only when it is being looked up from credential files), mirroring S3’s behavior.
There was a problem hiding this comment.
GCSBlobStoreEndpoint now has a lookupToken field that mirrors S3's lookupKey/lookupSecret pattern: it's true when the URL had no inline token (so we must load one from credential files), false when the URL supplied a token inline.
lookupSecretOnEachRequest()returns lookupToken, so credential-file refresh actually runs for the file-lookup case (also addressed a related comment above).getResourceURL()re-embeds the token into theblobstore://<token>@host/...prefix only when !lookupToken, so inline tokens round-trip and file-refreshed tokens don't get baked into serialized URLs.
I also added two test cases added under /backup/gcs/getResourceURL: one asserts an inline token survives parse -> serialize -> parse (ASSERT(gcs2->token == "tok"), !gcs2->lookupToken); the other simulates a file-refreshed token and asserts it is not serialized back into the URL.
| // GCS credential files are keyed by "@host" — no access-key prefix like S3's "accessKey@host". | ||
| std::string credentialFileKey() const override; | ||
|
|
||
| std::string getResourceURL(std::string resource, std::string params) const override; |
There was a problem hiding this comment.
This belong in the base S3BlobStoreEndpoint ?
There was a problem hiding this comment.
Hmm, I think this belongs here for GCS-specific parsing, since we have added two GCS-specific URL params (p=gcs, gcspid=…) and handles the bearer-token prefix placement.
The current layering is as such:
IBlobStoreEndpoint::getResourceURLproduces the genericblobstore://@host/...skeletonS3BlobStoreEndpoint::getResourceURLadds S3 credentialsGCSBlobStoreEndpoint::getResourceURLadds GCS params + bearer token
|
ctests pass against s3. And I ran 100k Joshua |
a4566a3 to
c5380b0
Compare
c5380b0 to
47f5750
Compare
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
|
@arnav-ag You seem to resolve the copilot review comments but do you address them (I looked at one and you didn't seem to have). Thanks. |
|
@saintstack the non-outdated comments were addressed, i just un-resolved them and added a comment under each of them to explain what was done to resolve it |
|
Thanks for the contribution @arnav-ag |
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Summary
GCSBlobStoreEndpointsubclassesS3BlobStoreEndpointsince the GCS XML API uses the same wire protocol (ListBucketResult, S3-style multipart uploads, same URL structure). All blob operations (list, read, write, multipart, delete) are inherited from S3 unchanged. Only auth and credential handling differ:"token"field fromFDB_BLOB_CREDENTIALSJSON)x-goog-project-idheader for bucket creationReference: https://docs.cloud.google.com/storage/docs/migrating
Selected via
provider=gcs(orp=gcs) URL parameter, e.g.:Approach
GCSBlobStoreEndpointplugs into theIBlobStoreEndpointextension points introduced by #12936:setRequestHeaders- Bearer auth instead of SigV4extractCredentialFields+credentialFileKey- reads the"token"field from credential files keyed by@host(S3 keys byaccessKey@host)getResourceURL- appendsp=gcsandgcspidso the serialized URL round-trips back to a GCS endpointcreateBucket- GCS requires the project ID at bucket creationupdateSecretis overridden only to bypassS3BlobStoreEndpoint::updateSecret's early-return on absent credentials; GCS keeps its bearer token in a dedicatedtokenfield rather than in S3'scredentials.URL parsing in
IBlobStoreEndpoint::fromStringrecognizesprovider/pandgcs_project_id/gcspid. Whenprovider=gcs, it constructs aGCSBlobStoreEndpoint; otherwise the existingS3BlobStoreEndpointpath is taken (default).Testing
Since GCS and S3 share the same wire protocol, the existing
MockS3Serverworks as a MockGCS for free (it doesn't validate auth headers). Rather than duplicating S3 test cases, the existings3client_test.shintegration tests are reused: a newUSE_MOCK_GCSpath startsMockS3Serverbut constructs GCS-style URLs and credential files, exercising the fullGCSBlobStoreEndpointcode path through all blob operations.GCS-specific logic (auth headers, URL parsing, credential extraction) is covered by C++ unit tests that mirror the existing S3 test patterns (
/backup/gcs/fromString,/backup/gcs/setRequestHeaders,/backup/gcs/getResourceURL).A
gcs_client_testctest target runs the integration suite withUSE_MOCK_GCS=true.Additionally, manual testing was done against a real GCS bucket using an OAuth2 application token.
Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.
For Release-Branches
If this PR is made against a release-branch, please also check the following:
release-branchormainif this is the youngest branch)