Skip to content

feat(storage): log effective gRPC transport configuration for DirectPath over Interconnect - #15026

Open
nidhiii-27 wants to merge 3 commits into
mainfrom
feat/storage-dp-interconnect-channel-diagnostics
Open

nidhiii-27 wants to merge 3 commits into
mainfrom
feat/storage-dp-interconnect-channel-diagnostics

Conversation

@nidhiii-27

@nidhiii-27 nidhiii-27 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds startup gRPC transport classification and configuration diagnostics for DirectPath over Cloud Interconnect (DP over GCI) in google-cloud-storage.

Key Changes

  • GrpcChannelTelemetry:
    • URI and host classification helpers (hasQueryParameter, detectTransportType, extractHost, isDirectPathInterconnectHost, grpcForceXdsIsSupported, isDirectPathInterconnectEnabled, resolveEffectiveTarget) for CloudPath, DirectPath, and DirectPathInterconnect, reusing OpenTelemetryBootstrappingUtils.extractServerAddress for host parsing and checking gRPC force-xds support via Class.forName(..., /* initialize= */ false, ...).
    • Startup diagnostic logging (logChannelConfiguration) reporting actionable WARNING messages for DirectPath over Cloud Interconnect misconfiguration, runtime gRPC force-xds support, and cases where setAttemptDirectPath(false) or unauthenticated/custom endpoint settings override setAttemptDirectPathXdsOverInterconnect(true), INFO for DirectPath over Cloud Interconnect, and CONFIG for CloudPath and standard DirectPath.
  • GrpcStorageOptions:
    • Fixes builder precedence so setAttemptDirectPath(false) disables DirectPath even when setAttemptDirectPathXdsOverInterconnect(true) or GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS_OVER_INTERCONNECT=true is set, and documents this precedence on Builder#setAttemptDirectPathXdsOverInterconnect.
    • Wires GrpcChannelTelemetry.logChannelConfiguration into resolveSettingsAndOpts.
  • GrpcChannelTelemetryTest:
    • Focused unit tests covering URI/host classification, startup diagnostic logs and warnings, environment variable precedence, and builder precedence.

@gemini-code-assist gemini-code-assist Bot 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.

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.

@nidhiii-27 nidhiii-27 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 16, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 16, 2026
@nidhiii-27
nidhiii-27 force-pushed the feat/storage-dp-interconnect-channel-diagnostics branch from 3718a90 to af5482f Compare November 18, 2026 06:51
@nidhiii-27 nidhiii-27 changed the title feat(storage): log effective gRPC transport and channel connection readiness feat(storage): log effective gRPC transport configuration for DirectPath over Interconnect Nov 18, 2026
@nidhiii-27 nidhiii-27 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 18, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 18, 2026
@nidhiii-27 nidhiii-27 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 18, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 18, 2026
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 18, 2026 10:20
@nidhiii-27
nidhiii-27 requested review from a team as code owners November 18, 2026 10:20
@nidhiii-27 nidhiii-27 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 18, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 18, 2026
return;
}
LOG.log(
Level.INFO,

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.

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.

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.

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");

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.

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?

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.

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

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.

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.

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.

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)

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

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.

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) {

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.

Catching Throwable swallows JVM errors like OutOfMemoryError or StackOverflowError.

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.

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)) {

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.

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.

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.

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)

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.

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?

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.

Done — documented the setAttemptDirectPath(false) and GOOGLE_CLOUD_DISABLE_DIRECT_PATH precedence in Builder#setAttemptDirectPathXdsOverInterconnect Javadoc.

Co-authored by AI Agent

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

ai-generated Pull Request generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants