Skip to content

fix(storage): gate default DirectPath endpoint on ALTS-capable credentials - #16711

Open
kalragauri wants to merge 2 commits into
googleapis:mainfrom
kalragauri:fix/storage-directpath-alts-creds-gate
Open

kalragauri wants to merge 2 commits into
googleapis:mainfrom
kalragauri:fix/storage-directpath-alts-creds-gate

Conversation

@kalragauri

@kalragauri kalragauri commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

On GCE and GCP serverless environments, DefaultOptionsGrpc() previously set EndpointOption to google-c2p:///storage.googleapis.com (and GrpcNumChannelsOption to 1) without checking whether the configured credentials support DirectPath ALTS.

Among UnifiedCredentialsOption types, only Application Default Credentials (GoogleDefaultCredentialsConfig) currently construct ALTS-capable channel credentials (grpc::GoogleDefaultCredentials()) in google-cloud-cpp. Other credential types (MakeComputeEngineCredentials(), MakeAccessTokenCredentials(), MakeServiceAccountCredentials(), MakeImpersonateServiceAccountCredentials(), MakeApiKeyCredentials(), MakeExternalAccountCredentials(), and MakeGDCHServiceAccountCredentials()) currently use TLS-only channel credentials (grpc::SslCredentials()). When paired with google-c2p:///storage.googleapis.com, TLS handshakes to DirectPath backends fail and gRPC falls back to the CloudPath front-end cluster over that single google-c2p channel instead of using the multi-channel storage.googleapis.com pool.

The Java and Go clients keep DirectPath for explicit credentials by attaching them as call credentials to Google default channel credentials. gRPC C++ cannot do the same through grpc::GoogleDefaultCredentials(), which takes no call credentials. This change therefore stops selecting the default DirectPath endpoint for those credentials; it does not make them ALTS-capable.

This change adds a CredentialsVisitor check (MaySupportDirectPathAlts() / ShouldDefaultToDirectPath()) in google/cloud/storage/internal/grpc/default_options.cc so the GCP/serverless google-c2p:///storage.googleapis.com default is selected only when UnifiedCredentialsOption is unset (defaults to ADC or uses an opaque caller-supplied GrpcCredentialOption) or holds GoogleDefaultCredentialsConfig. Other UnifiedCredentialsOption types fall back to the default storage.googleapis.com endpoint with max(4, hardware_concurrency()) channels.

Unchanged behavior:

  • Explicit EndpointOption, UniverseDomainOption, and GrpcNumChannelsOption overrides.
  • Caller-supplied GrpcCredentialOption without UnifiedCredentialsOption (opaque to the library).
  • DirectPathXdsOverInterconnectOption (?force-xds), which uses TLS over Interconnect.

@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Nov 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request restricts the default DirectPath endpoint (google-c2p:///storage.googleapis.com) to only be selected when the configured credentials support ALTS (such as Google Default Credentials or an opaque GrpcCredentialOption). For non-ALTS credentials, the library now falls back to the multi-channel CloudPath default. It introduces helper functions SupportsDirectPathAlts and ShouldDefaultToDirectPath to implement this logic, and adds comprehensive unit tests to verify the behavior across various credential types, GCP environments, and Interconnect configurations. No review comments were provided, and the changes look correct and conform to the repository style guide.

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.79%. Comparing base (fa26249) to head (110863c).

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #16711    +/-   ##
========================================
  Coverage   92.78%   92.79%            
========================================
  Files        2275     2275            
  Lines      227981   228136   +155     
========================================
+ Hits       211537   211693   +156     
+ Misses      16444    16443     -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalragauri kalragauri changed the title fix(storage): gate GCE DirectPath default on ALTS-capable credentials fix(storage): gate default DirectPath endpoint on ALTS-capable credentials Nov 26, 2026
@kalragauri
kalragauri marked this pull request as ready for review November 26, 2026 09:26
@kalragauri
kalragauri requested review from a team as code owners November 26, 2026 09:26

This branch has not been deployed

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

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant