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

gRPC/JSON transcoder: enable preserving route after headers modified #569

Merged
merged 1 commit into from
Apr 1, 2018

Conversation

ilackarms
Copy link
Contributor

the purpose of this PR is to add an option to the JSON-gRPC transcoder filter to allow preserving the original routing decision made by Envoy before this filter is called. Sometimes it is not desired that Envoy will not recalculate the route for a transcoded request; this option makes available that use case for the user.
Discussion can be found here: envoyproxy/envoy#2847

@ilackarms ilackarms changed the title skip recalculating route on grpc transcoder filter gRPC/JSON transcoder: skip recalculating route after headers modified Mar 19, 2018
@ilackarms ilackarms changed the title gRPC/JSON transcoder: skip recalculating route after headers modified gRPC/JSON transcoder: enable preserving route after headers modified Mar 19, 2018
@mattklein123
Copy link
Member

At a high level seems reasonable to me. @lizan can you take a look?

@lizan
Copy link
Member

lizan commented Mar 20, 2018

While the change here and the code looks reasonable, as I questioned in envoyproxy/envoy#2847, I'm curious if this is JSON-gRPC specific or it should be handled generically, e.g. a flag to allow Envoy to preserve the route entry of an incoming request and not let filters to modify.

@mattklein123
Copy link
Member

@lizan yup let's find out more details first.

@ilackarms
Copy link
Contributor Author

@lizan I'm not sure about other use cases for clearRouteCache(). It makes sense to me that it would be up to the filter to determine whether the route must be recalculated. I also think the result of allowing "passthrough" of the original routing decision would have a different meaning depending on the filter that was passing this decision through.

In theory, if we had a filter that was intentionally designed to modify a request that could otherwise be routed before the filter acted on it, we'd want to delegate to the filter in that case. However it's satisfactory for my use case that this option be generalized, so long as it's available for the gRPC transcoder filter 😄

// If set to true, Envoy will determine the cluster to
// route to based on the route for the incoming request
// Defaults to false.
bool skip_recalculating_route = 5;
Copy link
Member

Choose a reason for hiding this comment

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

Name this like use_incoming_request_route? Also document this is not recommended in the situation that native-gRPC and JSON-gRPC co-exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about match_incoming_request_route? (match is more descriptive than use)

Copy link
Member

Choose a reason for hiding this comment

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

SGTM.

@ilackarms ilackarms force-pushed the skip-recalculating-route branch from 0c7e29e to 3c2d865 Compare March 20, 2018 22:45
@@ -55,4 +55,16 @@ message GrpcJsonTranscoder {
// `JsonPrintOptions <https://developers.google.com/protocol-buffers/docs/reference/cpp/
// google.protobuf.util.json_util#JsonPrintOptions>`_.
PrintOptions print_options = 3;


// Whether to skip recalculating the route after the
Copy link
Member

Choose a reason for hiding this comment

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

"Whether to keep the incoming request route"? To be precise, recalculation doesn't happen with in the filter, it is calculated when it is necessary.

Also please reflow the comment, the column limit is 100.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

afaict there are no columns past 100 (max is 83 that i see)
can you show me the line that is over?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying you're past 100, but you can reflow (fit more words in one line as long as it is below 100), I usually put the paragraph in one line and let tools/check_format.py fix to fix them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

// Note: this will require routes to be added to match
// the incoming HTTP requests rather than the outgoing
// requests (after transcoding). This means routes that
// point directly to gRPC services cannot be reused for
Copy link
Member

Choose a reason for hiding this comment

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

Please clarify what is meant here. I think you're saying that if a route in a RouteConfiguration is used for a gRPC service that is not transcoded, we can't make use of it in combination with match_incoming_request_route to perform transcoding. Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that is correct. Would you like me to clarify that in the comment?

@htuch htuch self-assigned this Mar 21, 2018
@htuch
Copy link
Member

htuch commented Mar 25, 2018

@ilackarms friendly ping.

@htuch
Copy link
Member

htuch commented Mar 29, 2018

@ilackarms friendly ping again.

@ilackarms
Copy link
Contributor Author

@htuch sorry for the delay

Copy link
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

LGTM, please fix DCO.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM. Small nit. Thank you!


// Whether to keep the incoming request route after the outgoing headers have been transformed to
// the match the upstream gRPC service. Note: This means that routes for gRPC services that are
// not transcoded cannot be used in combination with match_incoming_request_route
Copy link
Member

Choose a reason for hiding this comment

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

nit: Please italicize "match_incoming_request_route" and end sentence with a period.

@ilackarms ilackarms force-pushed the skip-recalculating-route branch from 02c1d01 to 748fe07 Compare March 30, 2018 00:24
htuch
htuch previously approved these changes Mar 30, 2018
@mattklein123
Copy link
Member

@ilackarms can you fix DCO? Feel free to squash/rebase and force push if needed. Sorry for the trouble.

@ilackarms
Copy link
Contributor Author

@mattklein123 i added the sign off but it looks like DCO is still a red X. any idea what i'm missing?

@lizan
Copy link
Member

lizan commented Mar 31, 2018

@ilackarms You need Sign-off for every non-merge commit, feel free to squash all commit to one and add sign-off to that.

Signed-off-by: ilackarms <sdw35@cornell.edu>
@ilackarms ilackarms force-pushed the skip-recalculating-route branch from b8d492e to 6951506 Compare April 1, 2018 19:04
@ilackarms
Copy link
Contributor Author

got it. thanks @lizan

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Cool, thanks.

@mattklein123 mattklein123 merged commit c4590ec into envoyproxy:master Apr 1, 2018
htuch pushed a commit to envoyproxy/envoy that referenced this pull request Apr 10, 2018
…2848)

the purpose of this PR is to add an option to the JSON-gRPC transcoder filter to allow preserving the original routing decision made by Envoy before this filter is called. Sometimes it is not desired that Envoy will not recalculate the route for a transcoded request; this option makes available that use case for the user.

This change depends on envoyproxy/data-plane-api#569 where the option to skip has been added as a parameter for the filter config

Discussion can be found here: #2847

Risk Level: Medium

Testing:
A single unit test that verifies that, when the option is enabled, decoder_callbacks_->clearRouteCache() is not called.

The change was also tested manually, where the outgoing route was matched based on the incoming :path header, rather than the outgoing.

Addresses #2847

Signed-off-by: ilackarms <sdw35@cornell.edu>
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.

4 participants