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

Support tenant header propagation in query service #4141

Closed

Conversation

pavolloffay
Copy link
Member

Support tenant header propagation in the query HTTP APIs.

Our use case is to properly propagate tenant name (set in a configurable header) through the query service to the Tempo grpc plugin (right only the authorization header is propagated which is a bit of hack https://github.com/grafana/tempo/blob/main/cmd/tempo-query/tempo/plugin.go#L329-LL330)

@pavolloffay pavolloffay requested a review from a team as a code owner January 9, 2023 15:19
@pavolloffay pavolloffay requested a review from yurishkuro January 9, 2023 15:19
@codecov
Copy link

codecov bot commented Jan 9, 2023

Codecov Report

Base: 97.19% // Head: 97.14% // Decreases project coverage by -0.04% ⚠️

Coverage data is based on head (e8fe0bb) compared to base (7f91c29).
Patch coverage: 81.25% of modified lines in pull request are covered.

❗ Current head e8fe0bb differs from pull request most recent head 6373e19. Consider uploading reports for the commit 6373e19 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4141      +/-   ##
==========================================
- Coverage   97.19%   97.14%   -0.05%     
==========================================
  Files         295      295              
  Lines       17413    17436      +23     
==========================================
+ Hits        16924    16938      +14     
- Misses        394      400       +6     
- Partials       95       98       +3     
Flag Coverage Δ
unittests 97.14% <81.25%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/bearertoken/context.go 81.25% <70.00%> (-18.75%) ⬇️
plugin/storage/grpc/shared/grpc_client.go 84.61% <75.00%> (-1.10%) ⬇️
cmd/query/app/flags.go 100.00% <100.00%> (ø)
cmd/query/app/server.go 94.64% <100.00%> (ø)
pkg/bearertoken/http.go 100.00% <100.00%> (ø)
plugin/storage/badger/spanstore/reader.go 95.49% <0.00%> (-0.72%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -93,6 +96,7 @@ func AddFlags(flagSet *flag.FlagSet) {
flagSet.String(queryStaticFiles, "", "The directory path override for the static assets for the UI")
flagSet.String(queryUIConfig, "", "The path to the UI configuration file in JSON format")
flagSet.Bool(queryTokenPropagation, false, "Allow propagation of bearer token to be used by storage plugins")
flagSet.String(queryTenantPropagation, "", "Enables propagation of a tenant header")
Copy link
Member

Choose a reason for hiding this comment

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

unclear description - is this a boolean or the name of the header?

@@ -44,6 +44,7 @@ const (
queryStaticFiles = "query.static-files"
queryUIConfig = "query.ui-config"
queryTokenPropagation = "query.bearer-token-propagation"
queryTenantPropagation = "query.tenant-propagation"
Copy link
Member

Choose a reason for hiding this comment

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

Please see https://github.com/jaegertracing/jaeger/pull/3688/files, there is already flag defined for the tenancy, can we not reuse that?

const contextKey = contextKeyType(iota)
const (
bearerTokenContextKey = contextKeyType(iota)
tenantHeaderContextKey
Copy link
Member

Choose a reason for hiding this comment

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

We have pkg/config/tenancy, I would rather consolidate all tenancy-related code there, not mix with bearer token.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's pkg/tenancy . I totally forgot about #3688. I will try to adjust the PR to use the tenancy package. It seems that only the ingestion part is using it for now.

@joe-elliott
Copy link
Member

joe-elliott commented Jan 9, 2023

Personal opinion is that this change should not be tied to tenancy. It would be more straightforward to add a flag that takes a list of headers and then propagate anything that matches.

@yurishkuro
Copy link
Member

It would be more straightforward to add a flag that takes a list of headers and then propagate anything that matches.

+1, the more we can generalize the better. Could the same be done with bearer token though? Or would it need some kind of mapping when headers are transitioned from HTTP to gRPC?

@pavolloffay
Copy link
Member Author

superseded by #4151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants