Skip to content

Add GCS blob store support via S3-compatible XML API with OAuth2 auth - #12975

Merged
saintstack merged 1 commit into
apple:mainfrom
arnav-ag:gcs-blob-store-standalone
Apr 21, 2026
Merged

saintstack merged 1 commit into
apple:mainfrom
arnav-ag:gcs-blob-store-standalone

Conversation

@arnav-ag

@arnav-ag arnav-ag commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GCSBlobStoreEndpoint subclasses S3BlobStoreEndpoint since 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:

  • Bearer token auth instead of SigV4
  • OAuth2 token refresh via credential files (reads "token" field from FDB_BLOB_CREDENTIALS JSON)
  • x-goog-project-id header for bucket creation

Reference: https://docs.cloud.google.com/storage/docs/migrating

Selected via provider=gcs (or p=gcs) URL parameter, e.g.:

blobstore://<token>@storage.googleapis.com/resource?bucket=my-bucket&p=gcs&gcspid=my-project&secure_connection=1

Approach

GCSBlobStoreEndpoint plugs into the IBlobStoreEndpoint extension points introduced by #12936:

  • setRequestHeaders - Bearer auth instead of SigV4
  • extractCredentialFields + credentialFileKey - reads the "token" field from credential files keyed by @host (S3 keys by accessKey@host)
  • getResourceURL - appends p=gcs and gcspid so the serialized URL round-trips back to a GCS endpoint
  • createBucket - GCS requires the project ID at bucket creation

updateSecret is overridden only to bypass S3BlobStoreEndpoint::updateSecret's early-return on absent credentials; GCS keeps its bearer token in a dedicated token field rather than in S3's credentials.

URL parsing in IBlobStoreEndpoint::fromString recognizes provider/p and gcs_project_id/gcspid. When provider=gcs, it constructs a GCSBlobStoreEndpoint; otherwise the existing S3BlobStoreEndpoint path is taken (default).

Testing

Since GCS and S3 share the same wire protocol, the existing MockS3Server works as a MockGCS for free (it doesn't validate auth headers). Rather than duplicating S3 test cases, the existing s3client_test.sh integration tests are reused: a new USE_MOCK_GCS path starts MockS3Server but constructs GCS-style URLs and credential files, exercising the full GCSBlobStoreEndpoint code 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_test ctest target runs the integration suite with USE_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.

  • The PR has a description, explaining both the problem and the solution.
  • The description mentions which forms of testing were done and the testing seems reasonable.
  • Every function/class/actor that was touched is reasonably well documented.

For Release-Branches

If this PR is made against a release-branch, please also check the following:

  • This change/bugfix is a cherry-pick from the next younger branch (younger release-branch or main if this is the youngest branch)
  • There is a good reason why this PR needs to go into a release branch and this reason is documented (either in the description above or in a linked GitHub issue)

@arnav-ag
arnav-ag force-pushed the gcs-blob-store-standalone branch 2 times, most recently from 0c6864f to a4566a3 Compare April 20, 2026 10:56
@arnav-ag

Copy link
Copy Markdown
Contributor Author

@saintstack could I get your review on this PR as a follow up to the refactor PR?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::fromString and knob help text to support provider=gcs (p=gcs) and gcspid parsing/round-tripping.
  • Adds GCS fixtures and test paths, including a new gcs_client_test ctest 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.

Comment thread fdbclient/tests/s3client_test.sh Resolved
Comment thread fdbclient/tests/s3client_test.sh Resolved

Future<Void> updateSecret() override;
bool extractCredentialFields(JSONDoc& account) override;

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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; }

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the lookup token flag similar to S3's as per the second half of this comment

Comment on lines +80 to +88
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);
}

Copilot AI Apr 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the blobstore://<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.

Comment thread fdbclient/tests/tests_common.sh Resolved
Comment thread fdbclient/GCSBlobStore.cpp Resolved

@saintstack saintstack left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let me try the PR locally. Checkout the copilot review. Seems like good stuff on review.

// 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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belong in the base S3BlobStoreEndpoint ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::getResourceURL produces the generic blobstore://@host/... skeleton
  • S3BlobStoreEndpoint::getResourceURL adds S3 credentials
  • GCSBlobStoreEndpoint::getResourceURL adds GCS params + bearer token

@saintstack

Copy link
Copy Markdown
Contributor

ctests pass against s3. And I ran 100k Joshua 20260420-230229-stack_all_gcs-82820e322525a967 compressed=True data_size=35846291 duration=5328341 ended=100000 fail_fast=10 max_runs=100000 pass=100000 priority=100 remaining=0 runtime=0:53:38 sanity=False started=100000 stopped=20260420-235607 submitted=20260420-230229 timeout=5400 username=stack_all_gcs

@arnav-ag
arnav-ag force-pushed the gcs-blob-store-standalone branch from a4566a3 to c5380b0 Compare April 21, 2026 04:36
@saintstack saintstack closed this Apr 21, 2026
@saintstack saintstack reopened this Apr 21, 2026
@arnav-ag
arnav-ag force-pushed the gcs-blob-store-standalone branch from c5380b0 to 47f5750 Compare April 21, 2026 05:10
@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-ide on Linux RHEL 9

  • Commit ID: c5380b0
  • Duration 0:31:17
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-arm on Linux CentOS 7

  • Commit ID: c5380b0
  • Duration 0:43:26
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr on Linux RHEL 9

  • Commit ID: c5380b0
  • Duration 1:10:16
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang on Linux RHEL 9

  • Commit ID: c5380b0
  • Duration 1:12:48
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-cluster-tests on Linux RHEL 9

  • Commit ID: c5380b0
  • Duration 3:00:05
  • Result: ❌ FAILED
  • Error: Error while executing command: TEST_USERNAME=fdb-pr-${CODEBUILD_BUILD_NUMBER} make -C e2e foundationdb-pr-tests. Reason: exit status 2
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)
  • Cluster Test Logs zip file of the test logs (available for 30 days)

@saintstack saintstack closed this Apr 21, 2026
@saintstack saintstack reopened this Apr 21, 2026
@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-ide on Linux RHEL 9

  • Commit ID: 47f5750
  • Duration 0:23:05
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x

  • Commit ID: 47f5750
  • Duration 0:36:20
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang-arm on Linux CentOS 7

  • Commit ID: 47f5750
  • Duration 0:43:28
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-macos on macOS Ventura 13.x

  • Commit ID: 47f5750
  • Duration 0:48:43
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr on Linux RHEL 9

  • Commit ID: 47f5750
  • Duration 1:03:24
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-clang on Linux RHEL 9

  • Commit ID: 47f5750
  • Duration 1:05:25
  • Result: ✅ SUCCEEDED
  • Error: N/A
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)

@saintstack

Copy link
Copy Markdown
Contributor

@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.

@arnav-ag

arnav-ag commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor Author

@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

@saintstack
saintstack merged commit d73e33f into apple:main Apr 21, 2026
@saintstack

Copy link
Copy Markdown
Contributor

Thanks for the contribution @arnav-ag

@foundationdb-ci

Copy link
Copy Markdown
Contributor

Result of foundationdb-pr-cluster-tests on Linux RHEL 9

  • Commit ID: 47f5750
  • Duration 3:00:12
  • Result: ❌ FAILED
  • Error: Error while executing command: TEST_USERNAME=fdb-pr-${CODEBUILD_BUILD_NUMBER} make -C e2e foundationdb-pr-tests. Reason: exit status 2
  • Build Log terminal output (available for 30 days)
  • Build Workspace zip file of the working directory (available for 30 days)
  • Cluster Test Logs zip file of the test logs (available for 30 days)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants