credentials/alts: preserve boundAccessToken in altsTC.Clone - #9345
Conversation
`boundAccessToken` was added to `altsTC` in 00be1e1 ("[alts] Add plumbing for the bound access token field in the ALTS Start"), which also wired it into `ClientHandshake`, but `Clone` was not updated to copy it. A cloned credential therefore silently loses the token and performs the handshake without it. `Clone` is part of the exported `credentials.TransportCredentials` interface and is called inside grpc-go itself, for example in `balancer/rls/control_channel.go` where the RLS control channel is built with `bOpts.DialCreds.Clone()`. `TestCloneClient` already asserts on `side`, `hsAddress` and `accounts`, so this extends it to cover `boundAccessToken`. Without the fix it fails with: alts_test.go:121: cc.boundAccessToken = "", want "bound-access-token"
|
|
|
CLA is signed now, and all eight required Notes on the three red checks, none of which look related to this change:
Happy to rebase if that would help with any of these. |
eshitachandwani
left a comment
There was a problem hiding this comment.
Thank you for finding and fixing this.
Adding @easwars for a second review.
This has been fixed, please rebase on master to get it passing. |
|
@rockspore Can you PTAL? |
|
I think this is fine. Although |
|
@nileshpatil6 : Thanks for your contribution! |
Summary
altsTC.Clonedoes not copyboundAccessToken, so a cloned ALTS credential silently loses the token and performs its handshake without it.Detail
boundAccessTokenwas added to thealtsTCstruct in 00be1e1, "[alts] Add plumbing for the bound access token field in the ALTS Start". That commit added the field and consumed it inClientHandshake:but it did not update
Clone, which still copies only the four original fields:Cloneis part of the exportedcredentials.TransportCredentialsinterface, and grpc-go calls it internally, for example when building the RLS control channel inbalancer/rls/control_channel.go:so a clone taken there would hand the handshaker an empty
BoundAccessToken.To be upfront about reachability: there is currently no exported setter for
boundAccessToken, so today it is only assigned in tests and the field is always empty in production. This is a latent bug in the plumbing rather than one users can hit right now, but it will bite as soon as a setter lands, andClonedropping a field it should carry is wrong regardless.Change
One field added to the struct literal in
Clone.Testing
TestCloneClientalready asserts onside,hsAddressandaccounts, so I extended it to coverboundAccessTokenalongside them. Without the fix it fails:With the fix,
go test ./credentials/alts/...passes for the whole tree andgo vet ./credentials/alts/...is clean.RELEASE NOTES: none