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

Override env for shadow request #756

Merged
merged 6 commits into from Mar 5, 2021
Merged

Conversation

ashish-agg
Copy link
Contributor

@ashish-agg ashish-agg commented Mar 3, 2021

Overriding the environment value depending on the request type

@@ -51,6 +51,11 @@ const (
clientHTTPUnmarshalError = "client.http-unmarshal-error"
// clientTchannelReadError is the metric for tracking errors in reading tchannel response
clientTchannelUnmarshalError = "client.tchannel-unmarshal-error"

// shadow headers and environment
shadowHeader = "X-Uber-Shadow-Request"
Copy link
Contributor

Choose a reason for hiding this comment

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

Open source code cannot have uber specific anything. You should probably have a generic shadow header mechanism and set it to a specific value in the uber internal use-case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Valid point. I have renamed it to a more generic shadow header "X-Shadow-Request"

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

var headers map[string]string
if isShadowRequest {
headers = map[string]string{
"X-Uber-Shadow-Request": "true",
Copy link
Contributor

Choose a reason for hiding this comment

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

same deal as my other comment

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

Copy link
Contributor

@argouber argouber left a comment

Choose a reason for hiding this comment

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

Remove company-specific headers.

@@ -90,3 +90,5 @@ grpc.clientServiceNameMapping:
echo: echo
router.whitelistedPaths:
- /path/whitelisted
service.shadow.request.header: x-shadow-request
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these configs should go in the gateway config rather than env based config, see another similar header config example here: https://github.com/uber/zanzibar/blob/master/examples/example-gateway/build.yaml#L20

Copy link
Contributor Author

@ashish-agg ashish-agg Mar 4, 2021

Choose a reason for hiding this comment

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

Hi @rpatali , Actually I took the reference of http.clients.requestUUIDHeaderKey: x-request-uuid and ""sidecarRouter.default.http.callerHeader": "RPC-Caller"" the way it implemented here (https://github.com/uber/zanzibar/blob/master/examples/example-gateway/config/production.yaml#L53,) but yes your point is valid that this is not environment specific and it should be present while gateway is bootstraping.
I tried to put the shadow header key in the build.yaml of example gateway but I unable to fetch it through static config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Request changes have been incorporated.

@@ -90,3 +90,4 @@ grpc.clientServiceNameMapping:
echo: echo
router.whitelistedPaths:
- /path/whitelisted
service.shadow.env.override.enable: true
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed? if you have shadowRequestHeader in build.yaml, you override it otherwise you don't.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed with Tejas, Zanzibar is used by multiple teams(edge-gateway and presentation), etc.
This shadow header can pass to downstream services as well but we don't want to enforce env override for them as well. So I enable it through config.

Copy link
Contributor

@rpatali rpatali left a comment

Choose a reason for hiding this comment

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

LGTM

@ashish-agg ashish-agg merged commit 7b904da into master Mar 5, 2021
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.

None yet

4 participants