add response/request header options at route level#3838
add response/request header options at route level#3838zuercher merged 14 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Derek Argueta <dereka@pinterest.com>
There was a problem hiding this comment.
Hi, @derekargueta thank you for doing this. While the tests are failing (see: #3838 (comment)), I think this PR is on the right direction to provide the fix for the corresponding issue.
We also need to add a release note entry in version_history.rst. And potentially deprecation note if we want to deprecate this setting from route action level.
Some comments:
api/envoy/api/v2/route/route.proto
Outdated
| // through the enclosing :ref:`envoy_api_msg_route.RouteAction`. | ||
| // Headers specified at this level are applied before headers from the enclosing | ||
| // :ref:`envoy_api_msg_route.RouteAction`, | ||
| // :ref:`envoy_api_msg_route.RouteAction`, :ref:`envoy_api_msg_Route`, |
There was a problem hiding this comment.
I think we need to change :ref:`envoy_api_msg_Route` to :ref:`envoy_api_msg_route.Route`. Optionally adding Route label should be fine too i.e. :ref:`Router <envoy_api_msg_route.Route>`. The same everywhere else.
api/envoy/api/v2/route/route.proto
Outdated
| // | ||
| // Headers can be specified using *response_headers_to_add* in | ||
| // :ref:`envoy_api_msg_RouteConfiguration`. | ||
| // :ref:`envoy_api_msg_RouteConfiguration` or :ref:`envoy_msg_api_Route`. |
There was a problem hiding this comment.
Change this to :ref:`envoy_api_msg_route.Route`.
source/common/router/config_impl.h
Outdated
| const HeaderParser& requestHeaderParser() const { return *request_headers_parser_; }; | ||
| const HeaderParser& responseHeaderParser() const { return *response_headers_parser_; }; | ||
| const HeaderParser& requestHeaderParser() const { return *route_action_request_headers_parser_; }; | ||
| const HeaderParser& responseHeaderParser() const { return *route_action_response_headers_parser_; }; |
There was a problem hiding this comment.
This change for these two getters is reasonable since we used to work on RouteAction level. Do you think we need to have getters for the Route level too?
source/common/router/config_impl.cc
Outdated
| route_action_response_headers_parser_( | ||
| HeaderParser::configure(route.route().response_headers_to_add(), | ||
| route.route().response_headers_to_remove())), | ||
| request_headers_parser_(HeaderParser::configure(route.route().request_headers_to_add())), |
There was a problem hiding this comment.
It seems we try to configure parsers with route.route().request_headers_to_add() twice here, hence the relevant integration tests are failed.
Do you want to configure request_headers_parser_ by route.request_headers_to_add() instead? And regarding that, I think the newly added fields to Route (request_headers_to_add, response_headers_to_add, and response_headers_to_remove) needs to be accomodated in the test.
| } | ||
|
|
||
| // Validates behavior of request_headers_to_add at router, vhost, and route levels. | ||
| // Validates behavior of request_headers_to_add at router, vhost, and route action levels. |
There was a problem hiding this comment.
As mentioned above, we need to add tests for the route level too.
source/common/router/config_impl.cc
Outdated
| @@ -371,6 +376,7 @@ void RouteEntryImplBase::finalizeRequestHeaders(Http::HeaderMap& headers, | |||
| // Append user-specified request headers in the following order: route-level headers, | |||
There was a problem hiding this comment.
Modify the comment to add "route action level" to the sequence (route-level headers, route-action-level, ...).
|
|
||
| void RouteEntryImplBase::finalizeResponseHeaders( | ||
| Http::HeaderMap& headers, const RequestInfo::RequestInfo& request_info) const { | ||
| route_action_response_headers_parser_->evaluateHeaders(headers, request_info); |
There was a problem hiding this comment.
Probably adding a comment the same fashion with finalizeRequestHeaders here will add clarity.
Signed-off-by: Derek Argueta <dereka@pinterest.com>
Signed-off-by: Derek Argueta <dereka@pinterest.com>
|
@dio thanks for the review, tests coming up! |
Signed-off-by: Derek Argueta <dereka@pinterest.com>
Signed-off-by: Derek Argueta <dereka@pinterest.com>
|
Cool. @derekargueta please let me know when you think we can take another pass. Reminder: add an entry regarding this change in https://github.com/envoyproxy/envoy/blob/master/docs/root/intro/version_history.rst 🙂 Thank you! |
|
@derekargueta Sorry, could you fix the DCO check? Thank you. https://github.com/envoyproxy/envoy/blob/master/CONTRIBUTING.md#fixing-dco |
Signed-off-by: Derek Argueta <dereka@pinterest.com>
e03ae0e to
a2cf8eb
Compare
Signed-off-by: Derek Argueta <dereka@pinterest.com>
|
@dio sorry for the sluggish response - I've added a deprecation note to |
There was a problem hiding this comment.
Thanks, @derekargueta. Just a question and one more small thing. Thanks!
| [HttpConnectionManager](https://github.com/envoyproxy/envoy/blob/master/api/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.proto) | ||
| instead. | ||
| * Use of `response_headers_to_*` and `request_headers_to_add` are deprecated at the `RouteAction` | ||
| level. Please use the configuration options at the `Route` level. |
There was a problem hiding this comment.
In addition to this, please add [deprecated = true] annotation to the relevant fields inside RouteAction. e.g. for
envoy/api/envoy/api/v2/route/route.proto
Line 502 in 598f5c9
repeated core.HeaderValueOption request_headers_to_add = 12 [deprecated = true]; like what we have here for use_data_plane_proto in rls.proto
source/common/router/config_impl.h
Outdated
| const HeaderParser& requestHeaderParser() const { return *route_action_request_headers_parser_; }; | ||
| const HeaderParser& responseHeaderParser() const { | ||
| return *route_action_response_headers_parser_; | ||
| }; |
There was a problem hiding this comment.
Sorry missed this in the previous pass, if we remove response_headers_to_* and request_headers_to_add at RouteAction level (since it is deprecated in this PR) what will be returned in these two getters above? @derekargueta do you know which part of Envoy makes use of these two getters?
There was a problem hiding this comment.
From git grep, these 2 getters aren't used. The only reference to them in the code is in source/common/router/config_impl.cc, lines 401-402 and 382-383, and it's for these methods of the same name in the ConfigImpl and VirtualHostImpl classes. Compilation/tests seem fine with these two methods commented out. I only changed these to return route_action_...headers_parser to be consistent, but can update or remove these methods.
Signed-off-by: Derek Argueta <dereka@pinterest.com>
e7ae3b7 to
fb3a7f8
Compare
mattklein123
left a comment
There was a problem hiding this comment.
LGTM, small request. Thank you!
api/envoy/api/v2/route/route.proto
Outdated
| // through the enclosing :ref:`envoy_api_msg_route.RouteAction`. | ||
| // Headers specified at this level are applied before headers from the enclosing | ||
| // :ref:`envoy_api_msg_route.RouteAction`, | ||
| // :ref:`envoy_api_msg_route.RouteAction`, :ref:`envoy_api_msg_route.Route`, |
There was a problem hiding this comment.
Since RouteAction is deprecated just remove from docs now? (Any similar things need to be fixed?). Basically I would just like to make it as simple as possible to do the follow up deprecation change, so anything you can do now to make it less painful/error prone later would be great.
There was a problem hiding this comment.
Is there an annotation to exclude a protobuf field from showing up in the generated docs?
There was a problem hiding this comment.
htuch
left a comment
There was a problem hiding this comment.
LGTM also, modulo one minor comment.
source/common/router/config_impl.h
Outdated
| const HeaderParser& requestHeaderParser() const { return *route_action_request_headers_parser_; }; | ||
| const HeaderParser& responseHeaderParser() const { | ||
| return *route_action_response_headers_parser_; | ||
| }; |
zuercher
left a comment
There was a problem hiding this comment.
I added some comments on the protobuf docs.
api/envoy/api/v2/route/route.proto
Outdated
| // Specifies a set of headers that will be added to requests matching this | ||
| // route. Headers specified at this level are applied before headers from the | ||
| // enclosing :ref:`envoy_api_msg_route.VirtualHost` and | ||
| // enclosing :ref:`envoy_api_msg_route.Route` and |
There was a problem hiding this comment.
Shouldn't this say from the enclosing Route, VirtualHost, and RouteConfiguration (with appropriate links)?
api/envoy/api/v2/route/route.proto
Outdated
| // :ref:`envoy_api_msg_RouteConfiguration`. For more information, including | ||
| // details on header value syntax, see the documentation on | ||
| // headers from the enclosing :ref:`envoy_api_msg_route.VirtualHost`, | ||
| // :ref:`envoy_api_msg_RouteConfiguration`, and :ref:`envoy_api_msg_route.Route`. For more |
There was a problem hiding this comment.
Maybe put Route before VirtualHost (preserving the order in which they're applied)?
api/envoy/api/v2/route/route.proto
Outdated
| // | ||
| // Headers can be specified using *response_headers_to_add* in | ||
| // :ref:`envoy_api_msg_RouteConfiguration`. | ||
| // :ref:`envoy_api_msg_RouteConfiguration` or :ref:`envoy_api_msg_route.Route`. |
There was a problem hiding this comment.
Add VirtualHost to the places where response headers can be added.
Signed-off-by: Derek Argueta <dereka@pinterest.com>
Signed-off-by: Derek Argueta <dereka@pinterest.com>
Signed-off-by: Derek Argueta <dereka@pinterest.com>
Signed-off-by: Derek Argueta <dereka@pinterest.com>
api/envoy/api/v2/route/route.proto
Outdated
| // through the enclosing :ref:`envoy_api_msg_route.RouteAction`. | ||
| // Headers specified at this level are applied before headers from the enclosing | ||
| // :ref:`envoy_api_msg_route.RouteAction`, | ||
| // :ref:`envoy_api_msg_route.Route`, :ref:`envoy_api_msg_route.Route`, |
There was a problem hiding this comment.
Duplicated ref:`envoy_api_msg_route.Route` ?
Signed-off-by: Derek Argueta <dereka@pinterest.com>
While there, move header modification in some tests from route action level (deprecated in envoyproxy#3838) to route level. *Risk Level*: Low *Testing*: bazel test //test/... *Docs Changes*: Added *Release Notes*: Added Fixes envoyproxy#4249. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Description:
This adds the ability to specify
response_headers_to_*andrequest_headers_to_addat the route level, for #3520Risk Level: low
Testing: updated unit tests
Docs Changes: added
Fixes #Issue: #3520