Skip to content
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

Merged
merged 2 commits into from Dec 21, 2022

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Dec 21, 2022

Follow-up from #5853.

RELEASE NOTES:

  • rls: propagate headers received in RLS response to backends

return res, err
}
if res.Metatada == nil {
res.Metatada = metadata.Pairs("x-google-rls-data", dcEntry.headerData)
Copy link
Member

Choose a reason for hiding this comment

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

const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

t.Fatalf("Failed to start backend: %v", err)
}
t.Logf("Started TestService backend at: %q", backend.Address)
t.Cleanup(func() { backend.Stop() })
Copy link
Member

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?

Copy link
Contributor Author

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"
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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"
Copy link
Member

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?

@dfawley dfawley assigned easwars and unassigned dfawley Dec 21, 2022
@easwars easwars merged commit 5ff7dfc into grpc:master Dec 21, 2022
1 check passed
@easwars easwars deleted the rls_header_data branch December 21, 2022 21:18
easwars added a commit to easwars/grpc-go that referenced this pull request Dec 21, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants