-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
rls: propagate headers received in RLS response to backends #5883
Conversation
balancer/rls/picker.go
Outdated
return res, err | ||
} | ||
if res.Metatada == nil { | ||
res.Metatada = metadata.Pairs("x-google-rls-data", dcEntry.headerData) |
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.
const
?
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.
balancer/rls/picker_test.go
Outdated
EmptyCallF: func(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) { | ||
gotHeaderData := metadata.ValueFromIncomingContext(ctx, "x-google-rls-data") | ||
if len(gotHeaderData) != 1 || gotHeaderData[0] != headerDataContents { | ||
rpcErrCh <- fmt.Errorf("got metadata in `X-Google-RLS-Data` is %v, want %s", gotHeaderData, headerDataContents) |
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.
It seems like you could simplify this by just returning the error directly from the RPC?
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.
balancer/rls/picker_test.go
Outdated
t.Fatalf("Failed to start backend: %v", err) | ||
} | ||
t.Logf("Started TestService backend at: %q", backend.Address) | ||
t.Cleanup(func() { backend.Stop() }) |
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.
defer backend.Stop()
? Or t.Cleanup(backend.Stop)
instead?
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.
|
||
// Start a test backend which expects the header data contents sent from the | ||
// RLS server to be part of RPC metadata as X-Google-RLS-Data header. | ||
const headerDataContents = "foo,bar,baz" |
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 find this test case particularly interesting since header values are comma separated, aren't they?
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.
The actual value does not matter to the LB policy. So, I just put something in :)
Do you have a recommendation for a better value?
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.
No, I just thought it was interesting.
Just to confirm: this feature allows us to set exactly one header to exactly one value, right? I.e. if the config has commas as the value, we aren't expected to add multiple values to the same header key, right?
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.
this feature allows us to set exactly one header to exactly one value, right?
That's right.
|
||
// Start a test backend which expects the header data contents sent from the | ||
// RLS server to be part of RPC metadata as X-Google-RLS-Data header. | ||
const headerDataContents = "foo,bar,baz" |
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.
No, I just thought it was interesting.
Just to confirm: this feature allows us to set exactly one header to exactly one value, right? I.e. if the config has commas as the value, we aren't expected to add multiple values to the same header key, right?
Follow-up from #5853.
RELEASE NOTES: