-
Notifications
You must be signed in to change notification settings - Fork 69
feat: enable DirectPath bound token in InstantiatingGrpcChannelProvider #3572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lqiu96
merged 20 commits into
googleapis:main
from
rockspore:directpath-bound-token-with-patch
Feb 10, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
2f56310
wip
rockspore 88dc795
wip++
rockspore 25003a9
wip++
rockspore 53d3206
wip
rockspore 74a0166
Merge branch 'directpath-bound-token' into directpath-bound-token-wit…
rockspore d11c03f
wip++
rockspore 0b734ae
one more test case
rockspore 64a4399
tweak comment
rockspore a1d9691
Merge branch 'main' of https://github.com/googleapis/sdk-platform-jav…
rockspore 7c0ec55
remove local snapshots in pom.xml
rockspore 71f2e52
wip
rockspore e1a8dbf
merge with upstream
rockspore 84c9be4
move the alts call creds creation into the builder
rockspore 2287136
revert some out-of-scope format changes
rockspore 391829a
format
rockspore 1ed143c
Merge branch 'main' into directpath-bound-token-with-patch
rockspore 80ee661
check emptiness
rockspore beefd82
comment
rockspore 99d49b3
Merge branch 'main' into directpath-bound-token-with-patch
rockspore 28547bb
Merge branch 'main' into directpath-bound-token-with-patch
rockspore File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Can altsCallCredentials and mtlsS2ACallCredentials share the same variable? Something like hardBoundCallCredentials?
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.
Oh, from reading the code below, I'm assuming this is a limitation from directpath.
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.
Hmm, I guess we can at this point, because it's always one or the other. But does that provide any benefit?
If in the future, we want gRPC to use mTLS when falling back from DirectPath to CloudPath, we will need these two different creds again.
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.
Is it always going to be one or the other? I'd rather just have one variable to keep track of the hard bound callcredential state -> mtls vs alts if possible. Adding more variables makes it harder to keep track of all the combinations of possible states (mtls can be null or non-null + alts can be null or non-null).
Is this something that is in the works and you know that it will require multiple types of callcredentials? Or is this just a hypothetical example?
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's consolidate the discussion around keeping two credentials to this thread.
I believe so in normal use cases although at this point you can see that DirectPath enablement is also controlled by an environment variable. So in theory, I suppose the decision could change in the runtime so two credentials need to exist independently to ensure there is no interference.
Even when that env var switch gets removed in the future, IMO we should still keep two credentials separate because we use a list of allowed bound token types to control the enablement of them independently. From that perspective, it should be fairly straightforward to track the null-ness of these two variables - they are enabled by the enum in the list.
Our team has talked about that a few times but there is no concrete plan as of now. So yes it's fair to be considered as a hypothetical example.
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.
+1, the answer to "can DirectPath be used" could change from after this
transportChannelProvider
is built (.build()
) but before callingtransportChannelProvider.createSingleChannel()
.In general, I think it may be simpler to keep these two creds separate. I think that combining them would complicate our
isMtlsS2AHardBoundTokensEnabled
andisDirectPathBoundTokenEnabled
logic below. Since both can be true on GCE and DirectPath takes precedence over using S2A, I think we would end up needing to combine the logic from those functions if we wanted a singlehardBoundCallCredential
. While DirectPath and S2A are doing similar things when it comes to enabling the usage hard bound tokens, I think at this time it might be difficult to try and reason about them together like thisAdditionally, @lqiu96, from our discussion in #3591 (comment), It seems like creating 2 creds is ok, as they are created in the provider once, and are not exposed by the provider? That was a detailed discussion though, so I could be missing something.
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'm not entirely sure I'm following because I am still only see this as a limitation with how DirectPath is being resolved.
Correct me if I'm wrong. For hard bound tokens, even if MTLS_S2A and ALTS are both in the hard-bound list, only one of them is going to to be used, right? Even if both are currently resolved to be non-null. The intended logic is roughly as follows:
Changing how DirectPath is done is out of scope for this PR and two different hard-bound tokens can live here for now. I'm just not piecing together why two separate hard bound tokens need to exist (besides for the directpath limitation), since it's going to be either ALTS or MTLS, right? Or is there some fallback logic that I may be forgetting about.
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.
So due to the environment variable check inside
isDirectPathEnabled
which is called bycanUseDirectPath
used bycreateSingleChannel
, we have to keep these two credentials separated for now.I guess the remaining discussion is about whether it makes sense otherwise to keep these two credentials inside the object. You are right that only one of the bound tokens will be used in practice. So I agree there will be no technical reason preventing us from consolidating them into one private class member.
I tend to believe it's just our opinions on which way makes the code easier to reason and minimizes confusion that differ. As @rmehta19 pointed out,
isMtlsS2AHardBoundTokensEnabled
andisDirectPathBoundTokenEnabled
would both mutate thehardBoundCallCredentials
. IMHO, it feels less intuitive and more error-prone, if the order of populatinghardBoundCallCredentials
is accidentally changed or so. But I personally don't feel strongly about this. At the point, the environment variable check is gone for DirectPath enablement, I'm fine if it's concluded that onehardBoundCallCredentials
is the better way to go.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 agreed. Really either way is fine logic-wise, but I just want to be cautious of adding in so many additional credential variables (as it went from 1 to 3). Each may include multiple states and this increases the mental load when figuring out how channels are created, which channels are created, and which credentials are used for each channel used.