Skip to content

feat(storage): add support for DirectPath over Interconnect - #14006

Open
nidhiii-27 wants to merge 5 commits into
mainfrom
add-dp-over-gci
Open

feat(storage): add support for DirectPath over Interconnect#14006
nidhiii-27 wants to merge 5 commits into
mainfrom
add-dp-over-gci

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor
  • DirectPath over Interconnect Support (GAX): Added the attemptDirectPathXdsOverInterconnect option to enable on-premise xDS name resolution via the google-c2p:///<service>?force-xds target scheme.
  • GCP Platform Check Bypass: Modified DirectPath validation logic to bypass standard Google Compute Engine (GCE) environment checks when Interconnect is enabled.
  • Custom URI Validation: Enhanced endpoint validation to support and validate custom target URI formats containing the :/// syntax (e.g. google-c2p:///).
  • Storage Layer Integration: Added configuration options to GrpcStorageOptions to automatically rewrite hosts to storage-direct.googleapis.com and override the request authority to storage.googleapis.com for secure TLS handshakes.

@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 support for DirectPath xDS over Interconnect (on-premise xDS name resolution) in GrpcStorageOptions and InstantiatingGrpcChannelProvider, allowing GCE environment checks to be bypassed when enabled. It also updates endpoint validation to support custom URI schemes like google-c2p:/// and adds corresponding tests. The reviewer suggests dynamically adjusting the log level for the DirectPath fallback warning to avoid excessive warning spam in non-GCE environments, recommending Level.WARNING on GCE and Level.FINE elsewhere.

@nidhiii-27
nidhiii-27 marked this pull request as ready for review August 6, 2026 08:45
@nidhiii-27
nidhiii-27 requested review from a team as code owners August 6, 2026 08:45
if (needsCredentials()) {
return false;
}
// xDS over Interconnect is designed to work on-premise using arbitrary service credentials.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we check isAttemptDirectPathXdsOverInterconnect() before needsCredentials()?

If needsCredentials (above) evaluates to true, isCredentialDirectPathCompatible returns false. Then validateDirectPathState logs: "DirectPath is misconfigured. DirectPath is only compatible with com.google.auth.oauth2.ComputeEngineCredentials ."

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. Updated isCredentialDirectPathCompatible() to check isAttemptDirectPathXdsOverInterconnect() prior to needsCredentials(), preventing misleading credential misconfiguration warnings when using DirectPath over Interconnect.

Co-authored by AI Agent

private static final Set<String> SCOPES = ImmutableSet.of(GCS_SCOPE);
private static final String DEFAULT_HOST = "https://storage.googleapis.com";
private static final String DEFAULT_HOST_DIRECT_PATH = "https://storage-direct.googleapis.com";
private static final String DEFAULT_HOST_NO_SCHEME = "storage.googleapis.com";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These are unused and the string literals are hardcoded in rewriteHost() and overrideAuthority().

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. Replaced hardcoded string literals in rewriteHost() and overrideAuthority() with DEFAULT_HOST_DIRECT_PATH and DEFAULT_HOST_NO_SCHEME constants.

Co-authored by AI Agent

* Option for whether this client should attempt to use DirectPath over Interconnect (on-premise
* xDS name resolution).
*
* @since 2.45.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this the correct version?

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. Updated the @SInCE tag to 2.72.0 to reflect the current release version of google-cloud-storage.

Co-authored by AI Agent

} else {
// Case 3: credential is not correctly set
// Case 3: DirectPath is enabled, but xDS is not.
if (!isDirectPathXdsEnabled()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If a customer configures the new option setAttemptDirectPathXdsOverInterconnect(true) without explicitly setting the attemptDirectPathXds option:

isDirectPathEnabled is true but isDirectPathXdsEnabled evaluates to false because it only checks attemptDirectPathXds and the environment variable.

As a result, GAX logs a warning stating that xDS is not enabled. Is this intended behavior?

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. Updated isDirectPathXdsEnabled() to also account for isAttemptDirectPathXdsOverInterconnect(), ensuring that enabling DirectPath over Interconnect is correctly recognized as xDS-enabled and does not trigger misconfiguration warnings.

Co-authored by AI Agent

(com.google.api.gax.grpc.InstantiatingGrpcChannelProvider) tcp;

// Verify attemptDirectPathXdsOverInterconnect is set to true on the provider using reflection
java.lang.reflect.Field field =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

IIUC, using reflection in unit tests is fragile.
Can we instead expose @InternalApi public boolean isAttemptDirectPathXdsOverInterconnect() on
InstantiatingGrpcChannelProvider? This follows the established pattern of isDirectPathXdsEnabled and eliminates the reflective test hack.

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. Exposed @internalapi public boolean isAttemptDirectPathXdsOverInterconnect() on InstantiatingGrpcChannelProvider following the pattern of isDirectPathXdsEnabled(), and updated StorageOptionsBuilderTest to call it directly instead of using reflection.

Co-authored by AI Agent

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
29.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'gapic-generator-java-root'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@@ -134,6 +134,9 @@ public final class GrpcStorageOptions extends StorageOptions
private static final String GCS_SCOPE = "https://www.googleapis.com/auth/devstorage.full_control";

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.

Can you look into the feedback related to overrideAuthority here https://docs.google.com/document/d/1d9OS84flOtAWD9Bx4HGdzKFV2t1_XlB5l8YnXWUto7Q/edit?tab=t.0

*
* @since 2.72.0
*/
public GrpcStorageOptions.Builder setAttemptDirectPathXdsOverInterconnect(

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.

Add Beta API annotation, till the feature is GA

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.

3 participants