transcoding: Teach transcoding filter to be aware of per vhost / per route settings#11188
transcoding: Teach transcoding filter to be aware of per vhost / per route settings#11188mattklein123 merged 27 commits intoenvoyproxy:mainfrom
Conversation
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Informational: this is another place that #8669 would help.
api/envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto
Outdated
Show resolved
Hide resolved
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
euroelessar
left a comment
There was a problem hiding this comment.
Looks great! few minor comments
| Protobuf::DescriptorPool descriptor_pool_; | ||
| google::grpc::transcoding::PathMatcherPtr<MethodInfoSharedPtr> path_matcher_; | ||
| std::unique_ptr<google::grpc::transcoding::TypeHelper> type_helper_; | ||
| std::shared_ptr<google::grpc::transcoding::TypeHelper> type_helper_; |
There was a problem hiding this comment.
what does make this change needed?
| void initPerRouteConfig(); | ||
|
|
||
| JsonTranscoderConfig& config_; | ||
| const JsonTranscoderConfig* per_route_config_{nullptr}; |
There was a problem hiding this comment.
nit: const JsonTranscoderConfig* per_route_config_{}; is equivalent and looks like is more favored in the code base
There was a problem hiding this comment.
sounds good, changed in the whole file so it's all consistent
|
@htuch Can you advice please, what's a recommended way to make this filter opt-in? For instance, we want to disable it by default but then enable (with different configs) for subset of virtual hosts. |
|
We could remove the two validation rules for |
|
Yeah, per-route filter config override seems a good way to provide per-vhost opt-in. |
- services list can be empty (and means that filter is then disabled) - left the requirement on the descriptor set to be still specified (so that it's more explicit that the intention is to disable the filter / won't accidentally end up with missing descriptor field) Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
so I left required validation for descriptor, thinking that it's just going to be more explicit in the configuration... do we prefer to simply not have it specified at all? |
api/envoy/extensions/filters/http/grpc_json_transcoder/v3/transcoder.proto
Show resolved
Hide resolved
| // the service names specified here, but they won't be translated. | ||
| repeated string services = 2 [(validate.rules).repeated = {min_items: 1}]; | ||
| // If the list of services is empty, filter is considered disabled. | ||
| repeated string services = 2 [(validate.rules).repeated = {min_items: 0}]; |
There was a problem hiding this comment.
You can just drop the annotation completely if min_items is 0.
|
What is the status of this PR? Is it ready to review? Can someone merge main into it? /wait |
| JsonTranscoderConfig( | ||
| const envoy::extensions::filters::http::grpc_json_transcoder::v3::GrpcJsonTranscoder& | ||
| proto_config, | ||
| Api::Api& api, bool disabled); |
test/proto/BUILD
Outdated
| ) | ||
|
|
||
| envoy_proto_descriptor( | ||
| name = "helloworld_proto_descriptor", |
|
|
||
| void JsonTranscoderFilter::doTrailers(Http::ResponseHeaderOrTrailerMap& headers_or_trailers) { | ||
| if (error_ || !transcoder_) { | ||
| if (error_ || !transcoder_ || per_route_config_->disabled()) { |
There was a problem hiding this comment.
is it possible that per_route_config_ is not initialized in this call? e.g. decodeHeader() is not called.
Same question for maybeConvertGrpcStatus() function
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
…ue-11038 Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks LGTM with a small comment.
/wait
| google::grpc::transcoding::TranscoderInputStream& response_input, | ||
| std::unique_ptr<Transcoder>& transcoder, MethodInfoSharedPtr& method_info) const { | ||
|
|
||
| if (disabled_) { |
There was a problem hiding this comment.
Generally we don't do defensive coding like this. I would switch this to an ASSERT with a comment if you like.
…ue-11038 Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
mattklein123
left a comment
There was a problem hiding this comment.
LGTM but I think this needs a release note?
/wait
…-11038 Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
…-11038 Signed-off-by: Agata Cieplik <cieplik@dropbox.com>
|
@mattklein123 i adjusted the release notes, do you think it's ok? |
Commit Message:
Adding support for per-route grpc json transcoding filter.
Additional Description:
Risk Level: low (adds a new usage for the transcoding filter, doesn't change the current behavior / use cases)
Testing:
Docs Changes:
Release Notes:
Fixes #11038