Skip to content

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

Merged
htuch merged 5 commits into
envoyproxy:masterfrom
ilackarms:skip-recalculating-route
Apr 10, 2018
Merged

htuch merged 5 commits into
envoyproxy:masterfrom
ilackarms:skip-recalculating-route

Conversation

@ilackarms

Copy link
Copy Markdown
Contributor

json-grpc transcoder filter: add option to skip clearing the route cache

Description:

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.

Docs Changes:

Link to Data Plane PR

Release Notes:

Link to Data Plane PR (Same as above, unless I misunderstood)

[Optional Fixes #Issue]

Addresses #2847

[Optional API Changes:]
Link to Data Plane PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Call decoder_callbacks_->route() in before the header conversion if match_incoming_request_route is set, to make sure we're not depending on the behavior that HTTP conn manager pre-calculate route. Since route is cached, this call won't impact performance.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ilackarms friendly reminder.

@htuch htuch assigned lizan and htuch Mar 21, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: bool JsonTranscoderConfig::matchIncomingRequestRoute() const

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file and the .cc are out-of-sync (the newly declared field doesn't match). Can you update? Thanks?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

noticed this and hadn't had a chance to push the change. should be fixed now

@ilackarms
ilackarms force-pushed the skip-recalculating-route branch from f55ccd5 to 729be7f Compare March 29, 2018 20:03
htuch
htuch previously approved these changes Mar 30, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: You can make this a const if you initialize it in the constructor initializor list.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ping on this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

are you sure i can? this gets set from the proto_config passed to the constructor

@htuch

htuch commented Mar 30, 2018

Copy link
Copy Markdown
Member

@ilackarms this still has build failures.

@ilackarms

Copy link
Copy Markdown
Contributor Author

@htuch the build is failing because envoyproxy/data-plane-api#569 has not yet been merged.
i can update repository_locations.bzl with my fork of data-plane-api but i assumed it would be better to wait until that's merged

@ilackarms
ilackarms force-pushed the skip-recalculating-route branch from 1f04e68 to 73d7d6d Compare April 2, 2018 15:54
* This allows Envoy to select the upstream cluster based on the incoming request
* rather than the outgoing.
*/
bool matchIncomingRequestRoute();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: bool matchIncomingRequestInfo() const;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ping on this one.

@ilackarms

Copy link
Copy Markdown
Contributor Author

sorry for the delay on this; having some trouble running bazel on my machine at the moment

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo some nits. @ilackarms if you can do a quick cleanup PR we can merge this.

* This allows Envoy to select the upstream cluster based on the incoming request
* rather than the outgoing.
*/
bool matchIncomingRequestRoute();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ping on this one.

public:
GrpcJsonTranscoderFilterSkipRecalculatingTest() : GrpcJsonTranscoderFilterTest(true) {}
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move this down next to the relevant test.

class GrpcJsonTranscoderFilterTest : public testing::Test {
public:
GrpcJsonTranscoderFilterTest() : config_(bookstoreProtoConfig()), filter_(config_) {
GrpcJsonTranscoderFilterTest(const bool match_incoming_request_route = false)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: const bool doesn't really do anything here, jsut make it bool.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ping on this one.

Signed-off-by: ilackarms <[email protected]>
Signed-off-by: ilackarms <[email protected]>

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@htuch
htuch merged commit d41d06e into envoyproxy:master Apr 10, 2018
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