Repository navigation
fix(storage): gate default DirectPath endpoint on ALTS-capable credentials - #16711
kalragauri wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
On GCE and GCP serverless environments,
DefaultOptionsGrpc()previously setEndpointOptiontogoogle-c2p:///storage.googleapis.com(andGrpcNumChannelsOptionto1) without checking whether the configured credentials support DirectPath ALTS.Among
UnifiedCredentialsOptiontypes, only Application Default Credentials (GoogleDefaultCredentialsConfig) currently construct ALTS-capable channel credentials (grpc::GoogleDefaultCredentials()) ingoogle-cloud-cpp. Other credential types (MakeComputeEngineCredentials(),MakeAccessTokenCredentials(),MakeServiceAccountCredentials(),MakeImpersonateServiceAccountCredentials(),MakeApiKeyCredentials(),MakeExternalAccountCredentials(), andMakeGDCHServiceAccountCredentials()) currently use TLS-only channel credentials (grpc::SslCredentials()). When paired withgoogle-c2p:///storage.googleapis.com, TLS handshakes to DirectPath backends fail and gRPC falls back to the CloudPath front-end cluster over that singlegoogle-c2pchannel instead of using the multi-channelstorage.googleapis.compool.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
CredentialsVisitorcheck (MaySupportDirectPathAlts()/ShouldDefaultToDirectPath()) ingoogle/cloud/storage/internal/grpc/default_options.ccso the GCP/serverlessgoogle-c2p:///storage.googleapis.comdefault is selected only whenUnifiedCredentialsOptionis unset (defaults to ADC or uses an opaque caller-suppliedGrpcCredentialOption) or holdsGoogleDefaultCredentialsConfig. OtherUnifiedCredentialsOptiontypes fall back to the defaultstorage.googleapis.comendpoint withmax(4, hardware_concurrency())channels.Unchanged behavior:
EndpointOption,UniverseDomainOption, andGrpcNumChannelsOptionoverrides.GrpcCredentialOptionwithoutUnifiedCredentialsOption(opaque to the library).DirectPathXdsOverInterconnectOption(?force-xds), which uses TLS over Interconnect.