Repository navigation
feat(storage): log effective gRPC transport configuration for DirectPath over Interconnect - #15026
nidhiii-27 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces GrpcChannelTelemetry to monitor and log gRPC channel connectivity states and record channel creation latency metrics using OpenTelemetry. It integrates this telemetry into GrpcStorageOptions via a channel primer and adds comprehensive unit tests in GrpcChannelTelemetryTest. The review feedback recommends refactoring the telemetry implementation to avoid using a static ScheduledExecutorService (DEFAULT_SCHEDULER), which can lead to classloader leaks in containerized environments. Instead, it is suggested to pass the managed executor service from StorageOptions through the channel primer and telemetry start methods, updating the tests accordingly.
…ath over Interconnect [Generated-by: AI]
3718a90 to
af5482f
Compare
…nostics and tests [Generated-by: AI]
| return; | ||
| } | ||
| LOG.log( | ||
| Level.INFO, |
There was a problem hiding this comment.
Logging at Level.INFO writes to stderr on every gRPC client creation under JUL's default handler configuration, including CloudPath and standard DirectPath clients that never enabled DirectPath over Interconnect. By comparison, GrpcStorageFactory logs startup transport diagnostics at Level.CONFIG. Consider using Level.CONFIG (or Level.FINE) here, or keeping Level.INFO only when DirectPath over Interconnect is enabled or requested.
There was a problem hiding this comment.
Done — switched non-Interconnect startup transport logging (CloudPath and standard DirectPath) to Level.CONFIG to match GrpcStorageFactory, keeping Level.INFO only when DirectPath over Interconnect is requested.
Co-authored by AI Agent
|
|
||
| private static boolean detectGrpcForceXdsSupport() { | ||
| try { | ||
| Class<?> clazz = Class.forName("io.grpc.googleapis.GoogleCloudToProdNameResolver"); |
There was a problem hiding this comment.
Single-arg Class.forName runs GoogleCloudToProdNameResolver's static initializer (InternalCheckGcpEnvironment.isOnGcp(), which reads DMI metadata on Linux or spawns powershell.exe on Windows) whenever GrpcChannelTelemetry loads, even for CloudPath clients with DirectPath disabled. getDeclaredField does not need class initialization.
Should we use Class.forName("io.grpc.googleapis.GoogleCloudToProdNameResolver", /* initialize= */ false, GrpcChannelTelemetry.class.getClassLoader()) instead?
There was a problem hiding this comment.
Done — switched to Class.forName(..., /* initialize= */ false, GrpcChannelTelemetry.class.getClassLoader()) to avoid triggering GoogleCloudToProdNameResolver static initialization.
Co-authored by AI Agent
| Level.WARNING, | ||
| "DirectPath over Interconnect requires a gRPC version supporting force-xds (found " | ||
| + grpcVersion | ||
| + "). The force-xds query parameter will be ignored by the google-c2p resolver;" |
There was a problem hiding this comment.
Because this branch triggers whenever interconnectEnabled is true, it also fires for non-google-c2p endpoints (for example, NoCredentials or setAttemptDirectPath(false)), where there is no force-xds parameter and GCE will not use standard DirectPath. It also omits requested_transport_type=, unlike the other three log messages.
There was a problem hiding this comment.
Done — moved the endpoint-override check ahead of the force-xds support check (restricting the latter to requestedTransport == DIRECT_PATH_INTERCONNECT), added requested_transport_type= to the force-xds warning message, and added a unit test for the non-c2p + unsupported force-xds case.
Co-authored by AI Agent
| @Nullable Credentials credentials, | ||
| boolean attemptDirectPathXdsOverInterconnect) { | ||
| InstantiatingGrpcChannelProvider telemetryProvider = | ||
| (credentials == null || credentials instanceof NoCredentials) |
There was a problem hiding this comment.
This credentials handling in the 3-arg logChannelConfiguration is not pinned by tests: removing baseProvider.withCredentials(credentials) or dropping credentials instanceof NoCredentials still passes all four grpcStorageOptions_* tests because they either ignore logHandler.records or only check Level.WARNING.
There was a problem hiding this comment.
Done — added logHandler assertions to the grpcStorageOptions_* tests (pinning both baseProvider.withCredentials(credentials) and NoCredentials handling) and dropped the unreachable credentials == null check since GrpcStorageOptions guarantees non-null credentials.
Co-authored by AI Agent
| Class<?> clazz = Class.forName("io.grpc.googleapis.GoogleCloudToProdNameResolver"); | ||
| clazz.getDeclaredField("forceXds"); | ||
| return true; | ||
| } catch (Throwable e) { |
There was a problem hiding this comment.
Catching Throwable swallows JVM errors like OutOfMemoryError or StackOverflowError.
There was a problem hiding this comment.
Done — narrowed the catch clause to ReflectiveOperationException | LinkageError | SecurityException so JVM VirtualMachineErrors are not swallowed.
Co-authored by AI Agent
| } | ||
|
|
||
| private static String rewriteDirectPathInterconnectHost(String serviceAddress) { | ||
| if (!serviceAddress.contains(DIRECT_PATH_INTERCONNECT_INFIX)) { |
There was a problem hiding this comment.
No test covers resolveEffectiveTarget when the input host already contains -direct. (such as https://storage-direct.googleapis.com), so removing this guard would double-rewrite it without failing any test. Consider adding a test case with an already--direct. host.
There was a problem hiding this comment.
Done — added grpcStorageOptions_directPathOverInterconnect_doesNotDoubleRewriteDirectHost testing https://storage-direct.googleapis.com to ensure no double -direct. rewrite.
Co-authored by AI Agent
| .setEndpoint(endpoint) | ||
| .setAllowNonDefaultServiceAccount(true) | ||
| .setAttemptDirectPath(attemptDirectPath || attemptDirectPathXdsOverInterconnect) | ||
| .setAttemptDirectPath(attemptDirectPath) |
There was a problem hiding this comment.
Changing this to .setAttemptDirectPath(attemptDirectPath) aligns GrpcStorageOptions with InstantiatingGrpcChannelProvider so setAttemptDirectPath(false) disables DirectPath over Interconnect.
Should we note this precedence in Builder#setAttemptDirectPathXdsOverInterconnect's Javadoc alongside the existing NoCredentials and environment variable notes?
There was a problem hiding this comment.
Done — documented the setAttemptDirectPath(false) and GOOGLE_CLOUD_DISABLE_DIRECT_PATH precedence in Builder#setAttemptDirectPathXdsOverInterconnect Javadoc.
Co-authored by AI Agent
…tics [Generated-by: AI]
Summary
Adds startup gRPC transport classification and configuration diagnostics for DirectPath over Cloud Interconnect (DP over GCI) in
google-cloud-storage.Key Changes
GrpcChannelTelemetry:hasQueryParameter,detectTransportType,extractHost,isDirectPathInterconnectHost,grpcForceXdsIsSupported,isDirectPathInterconnectEnabled,resolveEffectiveTarget) forCloudPath,DirectPath, andDirectPathInterconnect, reusingOpenTelemetryBootstrappingUtils.extractServerAddressfor host parsing and checking gRPCforce-xdssupport viaClass.forName(..., /* initialize= */ false, ...).logChannelConfiguration) reporting actionableWARNINGmessages for DirectPath over Cloud Interconnect misconfiguration, runtime gRPCforce-xdssupport, and cases wheresetAttemptDirectPath(false)or unauthenticated/custom endpoint settings overridesetAttemptDirectPathXdsOverInterconnect(true),INFOfor DirectPath over Cloud Interconnect, andCONFIGfor CloudPath and standard DirectPath.GrpcStorageOptions:setAttemptDirectPath(false)disables DirectPath even whensetAttemptDirectPathXdsOverInterconnect(true)orGOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS_OVER_INTERCONNECT=trueis set, and documents this precedence onBuilder#setAttemptDirectPathXdsOverInterconnect.GrpcChannelTelemetry.logChannelConfigurationintoresolveSettingsAndOpts.GrpcChannelTelemetryTest: