GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: revert #3400: reintroduce experimental S2A integration in client libraries grpc transport by rmehta19 · Pull Request #3548 · googleapis/sdk-platform-java

This repository was archived by the owner on Oct 29, 2026. It is now read-only.

Conversation

@rmehta19

@rmehta19 rmehta19 commented Jan 7, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Revert #3400.

This PR re-introduces the S2A integration the Java Cloud SDK (initially introduced in #3326, and temporarily reverted in #3400).

This PR does this by reverting #3400 with the following patches:

  • load the S2A APIs via reflection. This allows us to merge the code while the S2A API is still experimental in gRPC-Java without introducing a diamond dependency conflict. Once the S2A APIs are stable, the reflection logic can be removed and the S2A API can be used directly (via a dependency on S2A API)
  • fix NPE (s2a fix: fix NPE. #3401)
  • use a different env var name for enabling the feature

Below is the original description from #3326

Modify the Client Libraries gRPC Channel builder to use mTLS via S2A if the experimental environment variable is set, S2A is available (We check this by using SecureSessionAgent utility), and a few more conditions (see shouldUseS2A).

Following https://google.aip.dev/auth/4115, Only attempt to use S2A after DirectPath and DCA (https://google.aip.dev/auth/4114) are ruled out as options. If conditions to use S2A are not met (env variable not set, or S2A is not running in environment, etc (shouldUseS2A returns false)), fall back to default TLS connection.

When we are creating S2A-enabled Grpc Channel Credentials, we first try to secure the connection between the client and the S2A via MTLS, using MTLS-MDS credentials. If MTLS-MDS credentials can't be loaded, then we fallback to a plaintext connection between the client and S2A.

The parallel go implementation : googleapis/google-api-go-client#1874 (now lives here: https://github.com/googleapis/google-cloud-go/blob/main/auth/internal/transport/cba.go)

S2A Java client: https://github.com/grpc/grpc-java/tree/master/s2a

Resolving b/376258193 means that S2A.java is no longer experimental

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rmehta19 added 2 commits January 6, 2025 17:09
@rmehta19
initial revert of googleapis#3400.
3d99673
@rmehta19
Path googleapis#3401.
9b4b405
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Jan 7, 2025
This was referenced Jan 7, 2025
fix: plumb mtlsEndpoint to gRPC Channel provider instead of setting it in EndpointContext. #3386
Closed
s2a fix: fix NPE. #3401
Closed
rmehta19 added 3 commits January 6, 2025 17:47
@rmehta19
Patch googleapis#3386.
ffa4e7b
@rmehta19
change env var name.
b03cb51
@rmehta19
fix comment.
451e31b
rmehta19
rmehta19 commented Jan 7, 2025
View reviewed changes
Comment thread .../google/api/generator/gapic/composer/grpc/goldens/samples/bookshopclient/AsyncGetBook.golden Outdated
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Google LLC

@rmehta19 rmehta19 Jan 7, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks like running mvn fmt:format resulted in all these changes. Perhaps these changes could be made in another PR and then can be removed from this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@zhumin8 zhumin8 Jan 7, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Looks like these are missed in #3513.
We will do a separate PR for these and you can remove from this PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rmehta19 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@rmehta19 rmehta19 Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks! with the latest merge of main, these changes have been removed from this PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rmehta19
Merge branch 'main' into s2a-integration-roll-forward
494e828
@rmehta19

rmehta19 commented Jan 7, 2025

Copy link
Copy Markdown
Contributor Author

@lqiu96 @blakeli0 @zhumin8 , please review, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rmehta19 added 2 commits January 7, 2025 08:44
@rmehta19
Merge branch 'main' into s2a-integration-roll-forward
22c82ad
@rmehta19
Merge branch 'main' into s2a-integration-roll-forward
2ce9003
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jan 9, 2025
xmenxk
xmenxk reviewed Jan 10, 2025
View reviewed changes
Comment thread gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java Outdated
Comment on lines +318 to +319
String s2AEnv;
s2AEnv = envProvider().getenv(S2A_ENV_ENABLE_USE_S2A);

@xmenxk xmenxk Jan 10, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

nit: this can be one line.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 13, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread gax-java/gax/src/main/java/com/google/api/gax/rpc/EndpointContext.java

/** Determine if S2A can be used */
@VisibleForTesting
boolean shouldUseS2A() {

@xmenxk xmenxk Jan 10, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There was a issue raised re: netty-tcnative dropping support for Windows and MacOS Intel platforms, do we want to add the runtime checks here an skip S2A if the code is running on an unsupported platforms?

We can also do that in a followup PR, but just to mention it here so we don't forget.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 13, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for flagging this Kui, I think this is fine to get to in a followup PR. Sent you a ping with some details.

(We can probably use System.getProperty("os.name") to get this info. Precedence for doing so is in existing DirectPath logic: https://github.com/googleapis/sdk-platform-java/blob/main/gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java#L368)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java Outdated
}
if (channelCredentials != null) {
// Create the channel using S2A-secured channel credentials.
builder = Grpc.newChannelBuilder(mtlsEndpoint, channelCredentials);

@xmenxk xmenxk Jan 10, 2025

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I assume this is what we discussed re: only pick the mtls endpoint when we know s2a will be used and directpath will not be used, but let know if otherwise. thanks

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Yes this is correct. We removed the logic in determineEndpoint in EndpointContext to set the mtls endpoint if shouldUseS2A returns true. We instead plumb down the mtls endpoint so that we use it only when we know DirectPath is not being used.

This is because the decision to use S2A and the decision to use DirectPath happen in different places (EndpointContext vs InstantiatingGrpcChannelProvider).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
rmehta19 added 2 commits January 13, 2025 08:33
@rmehta19
Merge branch 'main' into s2a-integration-roll-forward
e19dad4
@rmehta19
declare + define env var one line.
0807a2e
lqiu96
lqiu96 reviewed Jan 13, 2025
View reviewed changes
Comment thread gax-java/gax/src/main/java/com/google/api/gax/rpc/TransportChannelProvider.java Outdated
Comment on lines +93 to +108
/** True if the TransportProvider has no mtlsEndpoint set. */
boolean needsMtlsEndpoint();

/**
* Sets the endpoint to use when constructing a new {@link TransportChannel}.
*
* <p>This method should only be called if {@link #needsEndpoint()} returns true.
*/
TransportChannelProvider withEndpoint(String endpoint);

/**
* Sets the mtlsEndpoint to use when constructing a new {@link TransportChannel}.
*
* <p>This method should only be called if {@link #needsMtlsEndpoint()} returns true.
*/
TransportChannelProvider withMtlsEndpoint(String mtlsEndpoint);

@lqiu96 lqiu96 Jan 13, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Let me think about this a bit more. I'm not the biggest fan of adding these two public methods in needsMtlsEndpoint + withMtlsEndpoint and would prefer not to if possible.

I know this is a limitation regarding DirectPath and how that's determined. If we can't find a reasonable alternative, then I think I'm fine with this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@lqiu96 lqiu96 Jan 13, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Took a look at this and I think there are possible a few alternatives to what is in this PR. Not sure entirely what all the pros and cons are as of now, but just going to pose them as possibilities.

  1. Remove the .mtls substring when using directpath flow. This is probably the simplest option, but is pretty much a workaround. Given that S2A may end up being used much more, I don't think I would like endpoint resolution to be based on string find and replace.
  2. Create a default method canUseDirectPath() in the TransportChannelProvider interface
  default boolean canUseDirectPath() {
    return false;
  }

I believe this allows us to use it via the ClientContext to resolve the endpoint before we create the TransportChannel:
i.e.

    if (transportChannelProvider.needsEndpoint()) {
      if (transportChannelProvider.canUseDirectPath()) {
        transportChannelProvider =
            transportChannelProvider.withEndpoint(endpointContext.mtlsEndpoint());
      } else {
        transportChannelProvider = transportChannelProvider.withEndpoint(endpoint);
      }
    }

It shouldn't affect users who manually create InstantiatingGrpcChannelProvider since the logic still resides in there and is used during channel creation.

Let me talk with the team and see if there are any other potential concerns that I'm missing with this. I think option 2 might be a possibility and if not, then I think we can proceed with this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 14, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for looking into this Lawrence.

Remove the .mtls substring when using directpath flow. This is probably the simplest option, but is pretty much a workaround. Given that S2A may end up being used much more, I don't think I would like endpoint resolution to be based on string find and replace.

Agreed that this is probably the simplest option. However I also am hesitant about modifying the endpoint using string find and replace, as you pointed out.

Create a default method canUseDirectPath() in the TransportChannelProvider interface

I think I understand this, however I think it might not be possible without reworking a few things with canUseDirectPath:

Looking at canUseDirectPath, it calls:

  • canUseDirectPathWithUniverseDomain, which relies on endpoint being set
  • isCredentialDirectPathCompatible, which relies on credential being set in ClientContext

The second one is easy to resolve, just be sure to call transportChannelProvider.needsCredentials() before transportChannelProvider.canUseDirectPath() in ClientContext. The first one will probably require moving that check out of canUseDirectPath and into ClientContext. I think this list is complete, but we may find more when we go to implement this.

Also, I think small typo in example you provided, should it be?:

if (transportChannelProvider.needsEndpoint()) {
      if (transportChannelProvider.canUseDirectPath()) {
        transportChannelProvider =
            transportChannelProvider.withEndpoint(endpoint);
      } else {
        transportChannelProvider = transportChannelProvider.withEndpoint(endpointContext.mtlsEndpoint());
      }
    }

Also, perhaps we could change it to set the mtls endpoint only if shouldUseS2A and !canUseDirectPath, and use endpoint derived via endpointResolution in all other cases?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 15, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

As discussed offline, we will not plumb the mtls endpoint for now, and just set the mtls endpoint if S2A can be used in EndpointContext in 25445d3

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lqiu96
lqiu96 reviewed Jan 13, 2025
View reviewed changes
Comment thread gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

lqiu96
lqiu96 reviewed Jan 13, 2025
View reviewed changes
Comment thread gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

lqiu96
lqiu96 reviewed Jan 13, 2025
View reviewed changes
Comment thread gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

rmehta19 added 4 commits January 13, 2025 12:27
@rmehta19
remove duplicate builder initialization.
95e70d3
@rmehta19
Modify S2A API reflection log message.
b807294
@rmehta19
Merge branch 'main' into s2a-integration-roll-forward
882047c
@rmehta19
set mtls endpoint for S2A in EndpointContext.
25445d3
lqiu96
lqiu96 reviewed Jan 16, 2025
View reviewed changes
Comment thread gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

lqiu96
lqiu96 reviewed Jan 16, 2025
View reviewed changes
Comment thread gax-java/gax-grpc/src/main/java/com/google/api/gax/grpc/InstantiatingGrpcChannelProvider.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

lqiu96
lqiu96 reviewed Jan 16, 2025
View reviewed changes
Comment thread gax-java/gax/clirr-ignored-differences.xml Outdated
<method>* useS2A()</method>
</difference>
<!-- Ignore this as this was part of s2a-grpc ExperimentalApi revert -->
<!-- Ignore method addition to an TransportChannelProvider interface -->

@lqiu96 lqiu96 Jan 16, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
<!-- Ignore method addition to an TransportChannelProvider interface -->
<!-- Ignore method addition to TransportChannelProvider interface (InternalExtensionOnly) -->

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 16, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done in e921696

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lqiu96
lqiu96 reviewed Jan 16, 2025
View reviewed changes
Comment thread gax-java/gax/clirr-ignored-differences.xml Outdated
<method>*</method>
</difference>
<!-- Ignore this as this was part of s2a-grpc ExperimentalApi revert -->
<!-- Ignore abstract method addition to an EndpointContext -->

@lqiu96 lqiu96 Jan 16, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

nit: Adding the why (i.e. it's marked as internal)

Suggested change
<!-- Ignore abstract method addition to an EndpointContext -->
<!-- Ignore abstract method addition to an EndpointContext (InternalApi) -->

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@rmehta19 rmehta19 Jan 16, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Done in e921696

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
blakeli0
blakeli0 approved these changes Jan 21, 2025
View reviewed changes
@blakeli0

blakeli0 commented Jan 21, 2025

Copy link
Copy Markdown
Contributor

/gcbrun

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmehta19

rmehta19 commented Jan 21, 2025

Copy link
Copy Markdown
Contributor Author

@blakeli0 I see there are 2 failing checks. Looking at the logs, the failures seem unrelated to the changes in this PR, WDYT?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zhumin8

zhumin8 commented Jan 22, 2025

Copy link
Copy Markdown
Contributor

sonar check is not supported for forked branches. And you can ignore "Build with Airlock" check for now.

rmehta19 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmehta19 rmehta19 changed the title Revert #3400: Reintroduce experimental S2A integration in client libraries grpc transport feat: revert #3400: reintroduce experimental S2A integration in client libraries grpc transport Jan 22, 2025
@rmehta19

rmehta19 commented Jan 22, 2025

Copy link
Copy Markdown
Contributor Author

@zhumin8 does this PR look ok to you? If so, are you able to merge (as I don't have write access)? Thank you!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@blakeli0

blakeli0 commented Jan 22, 2025

Copy link
Copy Markdown
Contributor

@rmehta19 Please resolve the conflict in InstantiatingGrpcChannelProvider, which is probably caused by #3467. We'll merge it once it is resolved.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmehta19
resolve merge conflict.
b046dc9
@rmehta19

rmehta19 commented Jan 22, 2025

Copy link
Copy Markdown
Contributor Author

@rmehta19 Please resolve the conflict in InstantiatingGrpcChannelProvider, which is probably caused by #3467. We'll merge it once it is resolved.

Thanks @blakeli0, the conflict is resolved.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@blakeli0

blakeli0 commented Jan 22, 2025

Copy link
Copy Markdown
Contributor

/gcbrun

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmehta19

rmehta19 commented Jan 22, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I was looking through resolved comments and I found this one, I think mine and @lqiu96 's comments might have crossed at the same time..

I think the resolution is that we should be putting the

if (shouldUseS2A()) {
        return mtlsEndpoint();
      }

at the end of determineEndpoint() as "universe domain support with mtls may require this additional logic". Right now it's at the beginning. WDYT @lqiu96, @blakeli0?

I tested in an internal patch, having this at the beginning or end of determineEndpoint() works for our GCP use cases, and while S2A is experimental, shouldUseS2A() will anyways return false, so it won't impact customers (on or off GCP).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lqiu96

lqiu96 commented Jan 23, 2025

Copy link
Copy Markdown
Member

I was looking through resolved comments and I found this one, I think mine and @lqiu96 's comments might have crossed at the same time..

I think the resolution is that we should be putting the

if (shouldUseS2A()) {
        return mtlsEndpoint();
      }

at the end of determineEndpoint() as "universe domain support with mtls may require this additional logic". Right now it's at the beginning. WDYT @lqiu96, @blakeli0?

I tested in an internal patch, having this at the beginning or end of determineEndpoint() works for our GCP use cases, and while S2A is experimental, shouldUseS2A() will anyways return false, so it won't impact customers (on or off GCP).

Took another look at this and I'm curious about the behavior regarding S2A and having the resolved endpoint be the non-mtls endpoint. mtlsResolver simply determines to use the mtls endpoint or the non-mtls endpoint. Based on the logic, I think it's possible that the resolved endpoint ends up being non-mtls endpoint, but S2A is true.

Should we guard against this or return an error? I think in this case, we may need to put this towards the end.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmehta19
move S2A check to end of determineEndpoint.
6f56cff
@rmehta19

rmehta19 commented Jan 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I was looking through resolved comments and I found this one, I think mine and @lqiu96 's comments might have crossed at the same time..
I think the resolution is that we should be putting the

if (shouldUseS2A()) {
        return mtlsEndpoint();
      }

at the end of determineEndpoint() as "universe domain support with mtls may require this additional logic". Right now it's at the beginning. WDYT @lqiu96, @blakeli0?
I tested in an internal patch, having this at the beginning or end of determineEndpoint() works for our GCP use cases, and while S2A is experimental, shouldUseS2A() will anyways return false, so it won't impact customers (on or off GCP).

Took another look at this and I'm curious about the behavior regarding S2A and having the resolved endpoint be the non-mtls endpoint. mtlsResolver simply determines to use the mtls endpoint or the non-mtls endpoint. Based on the logic, I think it's possible that the resolved endpoint ends up being non-mtls endpoint, but S2A is true.

Should we guard against this or return an error? I think in this case, we may need to put this towards the end.

Thanks for looking @lqiu96. It would be an error to use S2A with a non-MTLS endpoint, because when we start using the MTLS_S2A hard bound tokens on the connection, the requests would get rejected. To be clear: if S2A is used, the resolved endpoint needs to be an MTLS endpoint.

Based on the logic, I think it's possible that the resolved endpoint ends up being non-mtls endpoint, but S2A is true.

I'm not sure I am following this. With this check in the beginning or end of determineEndpoint, if S2A(shouldUseS2A) is true, the resolved endpoint will be a MTLS endpoint. There is an early return however for GDCH, so I do think it makes sense to move the check to the end of determineEndpoint, because if GDCH is being used, a custom endpoint gets returned.

In 6f56cff I moved the check to the end of determineEndpoint.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lqiu96

lqiu96 commented Jan 23, 2025

Copy link
Copy Markdown
Member

if S2A(shouldUseS2A) is true, the resolved endpoint will be a MTLS endpoint.

Oh sorry, what I wrote was confusing. What I meant is that it is possible that the mtlsResolver may return a non-mtls endpoint while shouldUseS2A is true (enabled). It would be confusing since mtlsResolver ends up checking the things that are required to enable MTLS (i.e. the required env vars and keystore, etc). So user may have set up for S2A, but the environment is accidentally configured to non-mtls. In this case, it would be that the environment can use non-mtls, but the user is set up for S2A (trying to mTLS), which seems to be a whole set of configuration issues/ mismatch. In this case, I think we would want to error out?

Hopefully that is clearer about what I was trying to point out.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rmehta19

rmehta19 commented Jan 23, 2025

Copy link
Copy Markdown
Contributor Author

if S2A(shouldUseS2A) is true, the resolved endpoint will be a MTLS endpoint.

Oh sorry, what I wrote was confusing. What I meant is that it is possible that the mtlsResolver may return a non-mtls endpoint while shouldUseS2A is true (enabled). It would be confusing since mtlsResolver ends up checking the things that are required to enable MTLS (i.e. the required env vars and keystore, etc). So user may have set up for S2A, but the environment is accidentally configured to non-mtls. In this case, it would be that the environment can use non-mtls, but the user is set up for S2A (trying to mTLS), which seems to be a whole set of configuration issues/ mismatch. In this case, I think we would want to error out?

Hopefully that is clearer about what I was trying to point out.

Thanks for elaborating @lqiu96! I responded with detail on chat internally.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rmehta19 added 3 commits January 23, 2025 15:12
@rmehta19
update comment above S2A logic in determineEndpoint.
ea4e701
@rmehta19
Merge branch 'main' into s2a-integration-roll-forward
fa59ce8
@rmehta19
add more detail to S2A comment in determine endpoint.
aa6ba37
@lqiu96

lqiu96 commented Jan 24, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Thanks for the explanation. The changes LGTM! Will merge after the Graalvm checks. Sonar and airlock CI issues can be ignored.

rmehta19 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lqiu96

lqiu96 commented Jan 24, 2025

Copy link
Copy Markdown
Member

/gcbrun

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lqiu96
lqiu96 merged commit 65a0f11 into googleapis:main Jan 24, 2025
@release-please release-please Bot mentioned this pull request Jan 24, 2025
chore(main): release 2.52.0 #3576
Merged
diegomarquezp pushed a commit that referenced this pull request Jan 25, 2025
@release-please
chore(main): release 2.52.0 (#3576)
c5b9924
🤖 I have created a release *beep* *boop*
---


<details><summary>2.52.0</summary>

##
[2.52.0](v2.51.1...v2.52.0)
(2025-01-24)


### Features

* add support for new setAllowHardBoundTokens field.
([#3467](#3467))
([38431a2](38431a2))
* revert
[#3400](#3400):
reintroduce experimental S2A integration in client libraries grpc
transport
([#3548](#3548))
([65a0f11](65a0f11))


### Dependencies

* update dependency com.google.api-client:google-api-client-bom to
v2.7.2
([#3578](#3578))
([f6e5ad9](f6e5ad9))
* update dependency commons-codec:commons-codec to v1.17.2
([#3557](#3557))
([07ce801](07ce801))
* update dependency gitpython to v3.1.44
([#3559](#3559))
([e924db0](e924db0))
* update dependency org.checkerframework:checker-qual to v3.48.4
([#3560](#3560))
([a4726e9](a4726e9))
* update dependency smmap to v5.0.2
([#3561](#3561))
([6cd5d0d](6cd5d0d))
* update docker.io/library/alpine docker tag to v3.21.1
([#3551](#3551))
([edd5a4c](edd5a4c))
* update docker.io/library/alpine docker tag to v3.21.2
([#3580](#3580))
([f577ecd](f577ecd))
* update docker.io/library/maven:3.9.9-eclipse-temurin-11-alpine docker
digest to 9a259c6
([#3554](#3554))
([eb2cbd6](eb2cbd6))
* update docker.io/library/python:3.13.1-alpine3.20 docker digest to
9ab3b6e
([#3555](#3555))
([40a74fe](40a74fe))
* update google auth library dependencies to v1.31.0
([#3577](#3577))
([7fa879a](7fa879a))
* update googleapis/java-cloud-bom digest to c7c443f
([#3579](#3579))
([fcf40b7](fcf40b7))
* update repo-automation-bots digest to 0a12b5d
([#3464](#3464))
([b9c9d21](b9c9d21))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
svc-squareup-copybara pushed a commit to cashapp/misk that referenced this pull request Feb 11, 2025
@github-cash-renovate-jvm-2 @svc-squareup-copybara
This PR contains the following updates:
8a41324
| Package | Type | Package file | Manager | Update | Change |
|---|---|---|---|---|---|
|
[com.google.api.grpc:proto-google-common-protos](https://github.com/googleapis/sdk-platform-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`2.51.0` -> `2.52.0` |
|
[com.google.cloud:google-cloud-core-http](https://github.com/googleapis/sdk-platform-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`2.50.0` -> `2.51.0` |
|
[com.google.cloud:google-cloud-core](https://github.com/googleapis/sdk-platform-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`2.50.0` -> `2.51.0` |
| [com.google.api:gax](https://github.com/googleapis/sdk-platform-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | minor |
`2.60.0` -> `2.61.0` |
| [io.netty:netty-handler](https://netty.io/)
([source](https://github.com/netty/netty)) | dependencies |
misk/gradle/libs.versions.toml | gradle | patch | `4.1.117.Final` ->
`4.1.118.Final` |
| [io.netty:netty-bom](https://netty.io/)
([source](https://github.com/netty/netty)) | dependencies |
misk/gradle/libs.versions.toml | gradle | patch | `4.1.117.Final` ->
`4.1.118.Final` |
|
[com.autonomousapps.dependency-analysis](https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin)
| plugin | misk/gradle/libs.versions.toml | gradle | patch | `2.8.1` ->
`2.8.2` |
| [software.amazon.awssdk:sdk-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |
| [software.amazon.awssdk:sqs](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |
|
[software.amazon.awssdk:dynamodb-enhanced](https://aws.amazon.com/sdkforjava)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |
| [software.amazon.awssdk:dynamodb](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |
| [software.amazon.awssdk:aws-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |
| [software.amazon.awssdk:bom](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |
| [software.amazon.awssdk:auth](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.30.16` -> `2.30.17` |

---

### Release Notes

<details>
<summary>googleapis/sdk-platform-java
(com.google.api.grpc:proto-google-common-protos)</summary>

###
[`v2.52.0`](https://github.com/googleapis/sdk-platform-java/blob/HEAD/CHANGELOG.md#2520-2025-01-24)

##### Features

- add support for new setAllowHardBoundTokens field.
([#&#8203;3467](googleapis/sdk-platform-java#3467))
([38431a2](googleapis/sdk-platform-java@38431a2))
- revert
[#&#8203;3400](googleapis/sdk-platform-java#3400):
reintroduce experimental S2A integration in client libraries grpc
transport
([#&#8203;3548](googleapis/sdk-platform-java#3548))
([65a0f11](googleapis/sdk-platform-java@65a0f11))

##### Dependencies

- update dependency com.google.api-client:google-api-client-bom to
v2.7.2
([#&#8203;3578](googleapis/sdk-platform-java#3578))
([f6e5ad9](googleapis/sdk-platform-java@f6e5ad9))
- update dependency commons-codec:commons-codec to v1.17.2
([#&#8203;3557](googleapis/sdk-platform-java#3557))
([07ce801](googleapis/sdk-platform-java@07ce801))
- update dependency gitpython to v3.1.44
([#&#8203;3559](googleapis/sdk-platform-java#3559))
([e924db0](googleapis/sdk-platform-java@e924db0))
- update dependency org.checkerframework:checker-qual to v3.48.4
([#&#8203;3560](googleapis/sdk-platform-java#3560))
([a4726e9](googleapis/sdk-platform-java@a4726e9))
- update dependency smmap to v5.0.2
([#&#8203;3561](googleapis/sdk-platform-java#3561))
([6cd5d0d](googleapis/sdk-platform-java@6cd5d0d))
- update docker.io/library/alpine docker tag to v3.21.1
([#&#8203;3551](googleapis/sdk-platform-java#3551))
([edd5a4c](googleapis/sdk-platform-java@edd5a4c))
- update docker.io/library/alpine docker tag to v3.21.2
([#&#8203;3580](googleapis/sdk-platform-java#3580))
([f577ecd](googleapis/sdk-platform-java@f577ecd))
- update docker.io/library/maven:3.9.9-eclipse-temurin-11-alpine docker
digest to
[`9a259c6`](googleapis/sdk-platform-java@9a259c6)
([#&#8203;3554](googleapis/sdk-platform-java#3554))
([eb2cbd6](googleapis/sdk-platform-java@eb2cbd6))
- update docker.io/library/python:3.13.1-alpine3.20 docker digest to
[`9ab3b6e`](googleapis/sdk-platform-java@9ab3b6e)
([#&#8203;3555](googleapis/sdk-platform-java#3555))
([40a74fe](googleapis/sdk-platform-java@40a74fe))
- update google auth library dependencies to v1.31.0
([#&#8203;3577](googleapis/sdk-platform-java#3577))
([7fa879a](googleapis/sdk-platform-java@7fa879a))
- update googleapis/java-cloud-bom digest to
[`c7c443f`](googleapis/sdk-platform-java@c7c443f)
([#&#8203;3579](googleapis/sdk-platform-java#3579))
([fcf40b7](googleapis/sdk-platform-java@fcf40b7))
- update repo-automation-bots digest to
[`0a12b5d`](googleapis/sdk-platform-java@0a12b5d)
([#&#8203;3464](googleapis/sdk-platform-java#3464))
([b9c9d21](googleapis/sdk-platform-java@b9c9d21))

</details>

<details>
<summary>autonomousapps/dependency-analysis-android-gradle-plugin
(com.autonomousapps.dependency-analysis)</summary>

###
[`v2.8.2`](https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/blob/HEAD/CHANGELOG.md#Version-282)

-   \[Fix]: generate supergraph just once per variant (source set).

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6pm every weekday,before 2am
every weekday" in timezone Australia/Melbourne, Automerge - At any time
(no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

GitOrigin-RevId: 77625f13e2ef5d155af3a50a4e15fb8d98ebdd62
lqiu96 pushed a commit that referenced this pull request Feb 20, 2025
@rmehta19 @lqiu96
feat: revert #3400: reintroduce experimental S2A integration in clien…
fdeef5e
…t libraries grpc transport (#3548)

**Revert #3400.**

**This PR re-introduces the S2A integration the Java Cloud SDK
(initially introduced in #3326, and temporarily reverted in #3400).**

**This PR does this by reverting #3400 with the following patches:**
- load the S2A APIs via reflection. This allows us to merge the code
while the [S2A API is still experimental in
gRPC-Java](https://github.com/grpc/grpc-java/blob/master/s2a/src/main/java/io/grpc/s2a/S2AChannelCredentials.java)
without introducing a diamond dependency conflict. Once the S2A APIs are
stable, the reflection logic can be removed and the S2A API can be used
directly (via a dependency on S2A API)
- fix NPE (#3401)
- use a different env var name for enabling the feature


**Below is the original description from #3326**

Modify the Client Libraries gRPC Channel builder to use mTLS via S2A if
the experimental environment variable is set, S2A is available (We check
this by using [SecureSessionAgent
utility](https://github.com/googleapis/google-auth-library-java/blob/main/oauth2_http/java/com/google/auth/oauth2/SecureSessionAgent.java)),
and a few more conditions (see `shouldUseS2A`).

Following https://google.aip.dev/auth/4115, Only attempt to use S2A
after DirectPath and DCA (https://google.aip.dev/auth/4114) are ruled
out as options. If conditions to use S2A are not met (env variable not
set, or S2A is not running in environment, etc (`shouldUseS2A` returns
false)), fall back to default TLS connection.

When we are creating S2A-enabled Grpc Channel Credentials, we first try
to secure the connection between the client and the S2A via MTLS, using
[MTLS-MDS](https://cloud.google.com/compute/docs/metadata/overview#https-mds)
credentials. If MTLS-MDS credentials can't be loaded, then we fallback
to a plaintext connection between the client and S2A.

The parallel go implementation : googleapis/google-api-go-client#1874
(now lives here:
https://github.com/googleapis/google-cloud-go/blob/main/auth/internal/transport/cba.go)

S2A Java client: https://github.com/grpc/grpc-java/tree/master/s2a

Resolving b/376258193 means that S2A.java is no longer experimental
lqiu96 pushed a commit that referenced this pull request Feb 20, 2025
@release-please @lqiu96
chore(main): release 2.52.0 (#3576)
7a138b2
🤖 I have created a release *beep* *boop*
---


<details><summary>2.52.0</summary>

##
[2.52.0](v2.51.1...v2.52.0)
(2025-01-24)


### Features

* add support for new setAllowHardBoundTokens field.
([#3467](#3467))
([38431a2](38431a2))
* revert
[#3400](#3400):
reintroduce experimental S2A integration in client libraries grpc
transport
([#3548](#3548))
([65a0f11](65a0f11))


### Dependencies

* update dependency com.google.api-client:google-api-client-bom to
v2.7.2
([#3578](#3578))
([f6e5ad9](f6e5ad9))
* update dependency commons-codec:commons-codec to v1.17.2
([#3557](#3557))
([07ce801](07ce801))
* update dependency gitpython to v3.1.44
([#3559](#3559))
([e924db0](e924db0))
* update dependency org.checkerframework:checker-qual to v3.48.4
([#3560](#3560))
([a4726e9](a4726e9))
* update dependency smmap to v5.0.2
([#3561](#3561))
([6cd5d0d](6cd5d0d))
* update docker.io/library/alpine docker tag to v3.21.1
([#3551](#3551))
([edd5a4c](edd5a4c))
* update docker.io/library/alpine docker tag to v3.21.2
([#3580](#3580))
([f577ecd](f577ecd))
* update docker.io/library/maven:3.9.9-eclipse-temurin-11-alpine docker
digest to 9a259c6
([#3554](#3554))
([eb2cbd6](eb2cbd6))
* update docker.io/library/python:3.13.1-alpine3.20 docker digest to
9ab3b6e
([#3555](#3555))
([40a74fe](40a74fe))
* update google auth library dependencies to v1.31.0
([#3577](#3577))
([7fa879a](7fa879a))
* update googleapis/java-cloud-bom digest to c7c443f
([#3579](#3579))
([fcf40b7](fcf40b7))
* update repo-automation-bots digest to 0a12b5d
([#3464](#3464))
([b9c9d21](b9c9d21))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
@suztomo suztomo mentioned this pull request Nov 5, 2025
chore(2.59.x): release 2.59.3 #3982
Merged
@release-please release-please Bot mentioned this pull request Dec 11, 2025
chore(protobuf-4.x-rc): release 2.65.0-rc1 #3999
Merged
chingor13 pushed a commit to googleapis/google-cloud-java that referenced this pull request Mar 24, 2026
@release-please
chore(main): release 2.52.0 (#3576)
1dca4fb
🤖 I have created a release *beep* *boop*
---


<details><summary>2.52.0</summary>

##
[2.52.0](googleapis/sdk-platform-java@v2.51.1...v2.52.0)
(2025-01-24)


### Features

* add support for new setAllowHardBoundTokens field.
([#3467](googleapis/sdk-platform-java#3467))
([a43718a](googleapis/sdk-platform-java@a43718a))
* revert
[#3400](googleapis/sdk-platform-java#3400):
reintroduce experimental S2A integration in client libraries grpc
transport
([#3548](googleapis/sdk-platform-java#3548))
([ac0df2d](googleapis/sdk-platform-java@ac0df2d))


### Dependencies

* update dependency com.google.api-client:google-api-client-bom to
v2.7.2
([#3578](googleapis/sdk-platform-java#3578))
([a7e44e1](googleapis/sdk-platform-java@a7e44e1))
* update dependency commons-codec:commons-codec to v1.17.2
([#3557](googleapis/sdk-platform-java#3557))
([cc73611](googleapis/sdk-platform-java@cc73611))
* update dependency gitpython to v3.1.44
([#3559](googleapis/sdk-platform-java#3559))
([7bb00ac](googleapis/sdk-platform-java@7bb00ac))
* update dependency org.checkerframework:checker-qual to v3.48.4
([#3560](googleapis/sdk-platform-java#3560))
([1635d52](googleapis/sdk-platform-java@1635d52))
* update dependency smmap to v5.0.2
([#3561](googleapis/sdk-platform-java#3561))
([31f47b3](googleapis/sdk-platform-java@31f47b3))
* update docker.io/library/alpine docker tag to v3.21.1
([#3551](googleapis/sdk-platform-java#3551))
([d1f39cb](googleapis/sdk-platform-java@d1f39cb))
* update docker.io/library/alpine docker tag to v3.21.2
([#3580](googleapis/sdk-platform-java#3580))
([e68a19f](googleapis/sdk-platform-java@e68a19f))
* update docker.io/library/maven:3.9.9-eclipse-temurin-11-alpine docker
digest to 9a259c6
([#3554](googleapis/sdk-platform-java#3554))
([daba4ca](googleapis/sdk-platform-java@daba4ca))
* update docker.io/library/python:3.13.1-alpine3.20 docker digest to
9ab3b6e
([#3555](googleapis/sdk-platform-java#3555))
([212997a](googleapis/sdk-platform-java@212997a))
* update google auth library dependencies to v1.31.0
([#3577](googleapis/sdk-platform-java#3577))
([d047f2f](googleapis/sdk-platform-java@d047f2f))
* update googleapis/java-cloud-bom digest to c7c443f
([#3579](googleapis/sdk-platform-java#3579))
([1e4d088](googleapis/sdk-platform-java@1e4d088))
* update repo-automation-bots digest to 0a12b5d
([#3464](googleapis/sdk-platform-java#3464))
([760af88](googleapis/sdk-platform-java@760af88))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

4 more reviewers
@xmenxk xmenxk xmenxk left review comments
@zhumin8 zhumin8 zhumin8 left review comments
@blakeli0 blakeli0 blakeli0 approved these changes
@lqiu96 lqiu96 lqiu96 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size: l Pull request size is large.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@rmehta19 @lqiu96 @blakeli0 @zhumin8 @xmenxk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.