Skip to content

add response/request header options at route level#3838

Merged
zuercher merged 14 commits intoenvoyproxy:masterfrom
derekargueta:response_headers
Jul 25, 2018
Merged

add response/request header options at route level#3838
zuercher merged 14 commits intoenvoyproxy:masterfrom
derekargueta:response_headers

Conversation

@derekargueta
Copy link
Member

Description:
This adds the ability to specify response_headers_to_* and request_headers_to_add at the route level, for #3520
Risk Level: low
Testing: updated unit tests
Docs Changes: added
Fixes #Issue: #3520

Signed-off-by: Derek Argueta <dereka@pinterest.com>
@derekargueta derekargueta changed the title Response headers add response/request header options at route level Jul 11, 2018
@htuch htuch requested a review from ggreenway July 11, 2018 02:41
@htuch htuch assigned dio and unassigned ggreenway Jul 11, 2018
@htuch htuch requested review from dio and removed request for ggreenway July 11, 2018 16:57
Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

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

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:

// 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`,
Copy link
Member

@dio dio Jul 11, 2018

Choose a reason for hiding this comment

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

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.

//
// 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`.
Copy link
Member

@dio dio Jul 11, 2018

Choose a reason for hiding this comment

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

Change this to :ref:`envoy_api_msg_route.Route`.

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_; };
Copy link
Member

Choose a reason for hiding this comment

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

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?

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())),
Copy link
Member

Choose a reason for hiding this comment

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

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.
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned above, we need to add tests for the route level too.

@@ -371,6 +376,7 @@ void RouteEntryImplBase::finalizeRequestHeaders(Http::HeaderMap& headers,
// Append user-specified request headers in the following order: route-level headers,
Copy link
Member

Choose a reason for hiding this comment

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

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);
Copy link
Member

Choose a reason for hiding this comment

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

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>
@derekargueta
Copy link
Member Author

@dio thanks for the review, tests coming up!

Signed-off-by: Derek Argueta <dereka@pinterest.com>
Signed-off-by: Derek Argueta <dereka@pinterest.com>
@dio
Copy link
Member

dio commented Jul 14, 2018

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!

@dio
Copy link
Member

dio commented Jul 17, 2018

Signed-off-by: Derek Argueta <dereka@pinterest.com>
@derekargueta
Copy link
Member Author

@dio sorry for the sluggish response - I've added a deprecation note to DEPRECATED.md. Please let me know if I should add/change anything else. Thanks!

Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

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

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.
Copy link
Member

Choose a reason for hiding this comment

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

In addition to this, please add [deprecated = true] annotation to the relevant fields inside RouteAction. e.g. for

repeated core.HeaderValueOption request_headers_to_add = 12;
make it repeated core.HeaderValueOption request_headers_to_add = 12 [deprecated = true]; like what we have here for use_data_plane_proto in rls.proto

const HeaderParser& requestHeaderParser() const { return *route_action_request_headers_parser_; };
const HeaderParser& responseHeaderParser() const {
return *route_action_response_headers_parser_;
};
Copy link
Member

@dio dio Jul 21, 2018

Choose a reason for hiding this comment

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

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

Should we just get rid of them?

Copy link
Member

Choose a reason for hiding this comment

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

👍

Signed-off-by: Derek Argueta <dereka@pinterest.com>
dio
dio previously approved these changes Jul 22, 2018
Copy link
Member

@dio dio left a comment

Choose a reason for hiding this comment

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

Thanks, @derekargueta! LGTM.

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 request. Thank you!

// 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`,
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there an annotation to exclude a protobuf field from showing up in the generated docs?

Copy link
Member

Choose a reason for hiding this comment

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

// [#not-implemented-hide:] Not configuration. Workaround c++ protobuf issue with importing

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM also, modulo one minor comment.

const HeaderParser& requestHeaderParser() const { return *route_action_request_headers_parser_; };
const HeaderParser& responseHeaderParser() const {
return *route_action_response_headers_parser_;
};
Copy link
Member

Choose a reason for hiding this comment

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

Should we just get rid of them?

Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

I added some comments on the protobuf docs.

// 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
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this say from the enclosing Route, VirtualHost, and RouteConfiguration (with appropriate links)?

// :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
Copy link
Member

Choose a reason for hiding this comment

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

Maybe put Route before VirtualHost (preserving the order in which they're applied)?

//
// 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`.
Copy link
Member

Choose a reason for hiding this comment

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

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>
// 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`,
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated ref:`envoy_api_msg_route.Route` ?

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo remaining nit.

Signed-off-by: Derek Argueta <dereka@pinterest.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Thanks!

@zuercher zuercher merged commit ec0179a into envoyproxy:master Jul 25, 2018
PiotrSikora added a commit to PiotrSikora/envoy that referenced this pull request Sep 15, 2018
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>
zuercher pushed a commit that referenced this pull request Sep 19, 2018
While there, move header modification in some tests from
route action level (deprecated in #3838) to route level.

*Risk Level*: Low
*Testing*: bazel test //test/...
*Docs Changes*: Added
*Release Notes*: Added

Fixes #4249.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
@derekargueta derekargueta deleted the response_headers branch November 6, 2018 19:28
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.

6 participants