-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 #2848
Conversation
b80ddd8
to
f55ccd5
Compare
@@ -217,7 +223,9 @@ Http::FilterHeadersStatus JsonTranscoderFilter::decodeHeaders(Http::HeaderMap& h | |||
headers.insertMethod().value().setReference(Http::Headers::get().MethodValues.Post); | |||
headers.insertTE().value().setReference(Http::Headers::get().TEValues.Trailers); | |||
|
|||
decoder_callbacks_->clearRouteCache(); | |||
if (!config_.match_incoming_request_route()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilackarms friendly reminder.
match_incoming_request_route_ = proto_config.match_incoming_request_route(); | ||
} | ||
|
||
bool JsonTranscoderConfig::match_incoming_request_route() { |
There was a problem hiding this comment.
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
@@ -62,6 +62,14 @@ class JsonTranscoderConfig : public Logger::Loggable<Logger::Id::config> { | |||
std::unique_ptr<google::grpc::transcoding::Transcoder>& transcoder, | |||
const Protobuf::MethodDescriptor*& method_descriptor); | |||
|
|||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
f55ccd5
to
729be7f
Compare
@@ -74,6 +82,8 @@ class JsonTranscoderConfig : public Logger::Loggable<Logger::Id::config> { | |||
google::grpc::transcoding::PathMatcherPtr<const Protobuf::MethodDescriptor*> path_matcher_; | |||
std::unique_ptr<google::grpc::transcoding::TypeHelper> type_helper_; | |||
Protobuf::util::JsonPrintOptions print_options_; | |||
|
|||
bool match_incoming_request_route_{false}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping on this one.
There was a problem hiding this comment.
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
@ilackarms this still has build failures. |
@htuch the build is failing because envoyproxy/data-plane-api#569 has not yet been merged. |
20d30d4
to
1f04e68
Compare
Signed-off-by: ilackarms <[email protected]>
1f04e68
to
73d7d6d
Compare
* This allows Envoy to select the upstream cluster based on the incoming request | ||
* rather than the outgoing. | ||
*/ | ||
bool matchIncomingRequestRoute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: bool matchIncomingRequestInfo() const;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping on this one.
sorry for the delay on this; having some trouble running bazel on my machine at the moment |
Signed-off-by: ilackarms <[email protected]>
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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) {} | ||
}; | ||
|
There was a problem hiding this comment.
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.
@@ -197,17 +205,20 @@ TEST_F(GrpcJsonTranscoderConfigTest, InvalidVariableBinding) { | |||
|
|||
class GrpcJsonTranscoderFilterTest : public testing::Test { | |||
public: | |||
GrpcJsonTranscoderFilterTest() : config_(bookstoreProtoConfig()), filter_(config_) { | |||
GrpcJsonTranscoderFilterTest(const bool match_incoming_request_route = false) |
There was a problem hiding this comment.
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
.
@@ -74,6 +82,8 @@ class JsonTranscoderConfig : public Logger::Loggable<Logger::Id::config> { | |||
google::grpc::transcoding::PathMatcherPtr<const Protobuf::MethodDescriptor*> path_matcher_; | |||
std::unique_ptr<google::grpc::transcoding::TypeHelper> type_helper_; | |||
Protobuf::util::JsonPrintOptions print_options_; | |||
|
|||
bool match_incoming_request_route_{false}; |
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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