Skip to content

inbound: Add a header-modification route filter#1793

Merged
olix0r merged 2 commits intomainfrom
ver/inbound-route-filter-headers
Jun 28, 2022
Merged

inbound: Add a header-modification route filter#1793
olix0r merged 2 commits intomainfrom
ver/inbound-route-filter-headers

Conversation

@olix0r
Copy link
Member

@olix0r olix0r commented Jun 28, 2022

The Gateway API defines a header-rewriting filter that may be
attached to HTTP routes. This change updates the HTTP route types to
support a list of filters. The inbound proxy supports only the
header modifier filter. Additional filters will be added in follow-up
changes (see #1788 for an example of these additional filters).

Signed-off-by: Oliver Gould [email protected]

The Gateway API defines a [header-rewriting filter](gwapi) that may be
attached to HTTP routes. This change updates the HTTP route types to
support a list of filters. The inbound proxy supports only the
header modifier filter. Additional filters will be added in follow-up
changes (see #1788 for an example of these additional filters).

[gwapi]: https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRequestHeaderFilter

Signed-off-by: Oliver Gould <[email protected]>
@olix0r olix0r requested a review from a team as a code owner June 28, 2022 06:17
Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

looks good to me overall! couple of small suggestions, but they're not blockers.

req: &::http::Request<B>,
) -> Result<HttpRoutePermit> {
let (_, route) =
) -> Result<(HttpRoutePermit, RouteMatch<M::Summary>, &'m RoutePolicy<P>)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, maybe not important, but part of me kind of feels like if we're gonna return a tuple with more than three things in it, it should probably be a struct with named fields at that point

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case it's a file-local helper, so I don't think the type is worth it at this point.

Comment on lines 173 to 174
add: vec![("testkey".parse().unwrap(), "testval".parse().unwrap())],
..filter::ModifyRequestHeader::default()
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like it might be worth also having tests for set and remove, but since the actual filter mechanics are fairly simple and just call a HeaderMap method, that may not be worth the boilerplate?

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't think that needs to be tested from here. We could have tests for the filter::ModifyHeader type that exercised that, but this is just ensuring that the filter gets applied by the service. There's nothing that could change in this service to keep this test passing while breaking set/remove.

@hawkw
Copy link
Contributor

hawkw commented Jun 28, 2022

oh, another thought: at some level, it seems like we should probably be validating that a header modification route filter isn't setting any connection-level headers, or headers that are set by the underlying HTTP implementation. for example, if a route has a filter that adds a Content-Length header with an arbitrary value...that's probably always gonna be bad news, and we should maybe validate such filters at some point? but it could also be done when the route is created rather than in the proxy, i guess...

Replace vecs with BTree datastructures.

Signed-off-by: Oliver Gould <[email protected]>
@olix0r
Copy link
Member Author

olix0r commented Jun 28, 2022

we should probably be validating that a header modification route filter isn't setting any connection-level headers

agreed. we'll address that when we deal with creating the filters.

@olix0r olix0r merged commit 043f084 into main Jun 28, 2022
@olix0r olix0r deleted the ver/inbound-route-filter-headers branch June 28, 2022 22:29
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jun 30, 2022
This release updates the proxy's service discovery module to avoid
redundant load balancer updates that could cause unnecessary connection
churn.

This release also includes improvements to the proxy's retry handling of
gRPC requests. The proxy would not retry requests when a response's
status code was emitted in a TRAILERS frame. This has been fixed.

This release also includes a number of internal changes that set up for
per-route authorization. There should be no user-facing impact at this
point except for the introduction of additional metrics labels.

---

* build(deps): bump mio from 0.8.3 to 0.8.4 (linkerd/linkerd2-proxy#1760)
* build(deps): bump quote from 1.0.18 to 1.0.19 (linkerd/linkerd2-proxy#1761)
* build(deps): bump tower-service from 0.3.1 to 0.3.2 (linkerd/linkerd2-proxy#1762)
* build(deps): bump proc-macro2 from 1.0.39 to 1.0.40 (linkerd/linkerd2-proxy#1763)
* build(deps): bump syn from 1.0.96 to 1.0.98 (linkerd/linkerd2-proxy#1764)
* build(deps): bump prettyplease from 0.1.12 to 0.1.14 (linkerd/linkerd2-proxy#1766)
* build(deps): bump anyhow from 1.0.57 to 1.0.58 (linkerd/linkerd2-proxy#1767)
* dev: Update build settings (linkerd/linkerd2-proxy#1765)
* Dedupe discovery updates (linkerd/linkerd2-proxy#1759)
* build(deps): bump quote from 1.0.19 to 1.0.20 (linkerd/linkerd2-proxy#1768)
* deny: Remove tokio-util from exceptions (linkerd/linkerd2-proxy#1769)
* dev: Update memory contraints (linkerd/linkerd2-proxy#1770)
* Reorganize `server-policy` to set up for routes (linkerd/linkerd2-proxy#1771)
* inbound: Rename policy-enforcement layers (linkerd/linkerd2-proxy#1772)
* ci: Split fuzzer logic into a script (linkerd/linkerd2-proxy#1773)
* build(deps): bump prettyplease from 0.1.14 to 0.1.15 (linkerd/linkerd2-proxy#1775)
* build(deps): bump indexmap from 1.9.0 to 1.9.1 (linkerd/linkerd2-proxy#1776)
* integration: Cleanup test server (linkerd/linkerd2-proxy#1777)
* http-retry: Move the ReplayBody type into a module (linkerd/linkerd2-proxy#1778)
* inbound: Add route authorization labels (linkerd/linkerd2-proxy#1774)
* Rename HTTPRoutePermit to HttpRoutePermit (linkerd/linkerd2-proxy#1779)
* retry gRPC requests are immediately terminated by trailers (linkerd/linkerd2-proxy#1706)
* inbound: Record policy metrics for opaque-transport connections (linkerd/linkerd2-proxy#1780)
* build(deps): bump tj-actions/changed-files from 23 to 23.1 (linkerd/linkerd2-proxy#1782)
* build(deps): bump derive_arbitrary from 1.1.2 to 1.1.3 (linkerd/linkerd2-proxy#1783)
* build(deps): bump arbitrary from 1.1.2 to 1.1.3 (linkerd/linkerd2-proxy#1784)
* inbound: Record TCP metrics for forwarded TLS connections (linkerd/linkerd2-proxy#1785)
* inbound: Cleanup in preparation for route policies #1781 (linkerd/linkerd2-proxy#1786)
* Add HTTP route matchers to support the Gateway API (linkerd/linkerd2-proxy#1787)
* build(deps): bump unicode-normalization from 0.1.19 to 0.1.20 (linkerd/linkerd2-proxy#1789)
* build(deps): bump linked-hash-map from 0.5.4 to 0.5.6 (linkerd/linkerd2-proxy#1790)
* build(deps): bump smallvec from 1.8.0 to 1.8.1 (linkerd/linkerd2-proxy#1791)
* build(deps): bump jemalloc-sys from 0.5.0+5.3.0 to 0.5.1+5.3.0-patched (linkerd/linkerd2-proxy#1792)
* Introduce per-route authorization policies (linkerd/linkerd2-proxy#1781)
* inbound: Add a header-modification route filter (linkerd/linkerd2-proxy#1793)
* docs: update justfile man page link (linkerd/linkerd2-proxy#1794)

Signed-off-by: Oliver Gould <[email protected]>
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jun 30, 2022
This release updates the proxy's service discovery module to avoid
redundant load balancer updates that could cause unnecessary connection
churn.

This release also includes improvements to the proxy's retry handling of
gRPC requests. The proxy would not retry requests when a response's
status code was emitted in a TRAILERS frame. This has been fixed.

This release also includes a number of internal changes that set up for
per-route authorization. There should be no user-facing impact at this
point except for the introduction of additional metrics labels.

---

* build(deps): bump mio from 0.8.3 to 0.8.4 (linkerd/linkerd2-proxy#1760)
* build(deps): bump quote from 1.0.18 to 1.0.19 (linkerd/linkerd2-proxy#1761)
* build(deps): bump tower-service from 0.3.1 to 0.3.2 (linkerd/linkerd2-proxy#1762)
* build(deps): bump proc-macro2 from 1.0.39 to 1.0.40 (linkerd/linkerd2-proxy#1763)
* build(deps): bump syn from 1.0.96 to 1.0.98 (linkerd/linkerd2-proxy#1764)
* build(deps): bump prettyplease from 0.1.12 to 0.1.14 (linkerd/linkerd2-proxy#1766)
* build(deps): bump anyhow from 1.0.57 to 1.0.58 (linkerd/linkerd2-proxy#1767)
* dev: Update build settings (linkerd/linkerd2-proxy#1765)
* Dedupe discovery updates (linkerd/linkerd2-proxy#1759)
* build(deps): bump quote from 1.0.19 to 1.0.20 (linkerd/linkerd2-proxy#1768)
* deny: Remove tokio-util from exceptions (linkerd/linkerd2-proxy#1769)
* dev: Update memory contraints (linkerd/linkerd2-proxy#1770)
* Reorganize `server-policy` to set up for routes (linkerd/linkerd2-proxy#1771)
* inbound: Rename policy-enforcement layers (linkerd/linkerd2-proxy#1772)
* ci: Split fuzzer logic into a script (linkerd/linkerd2-proxy#1773)
* build(deps): bump prettyplease from 0.1.14 to 0.1.15 (linkerd/linkerd2-proxy#1775)
* build(deps): bump indexmap from 1.9.0 to 1.9.1 (linkerd/linkerd2-proxy#1776)
* integration: Cleanup test server (linkerd/linkerd2-proxy#1777)
* http-retry: Move the ReplayBody type into a module (linkerd/linkerd2-proxy#1778)
* inbound: Add route authorization labels (linkerd/linkerd2-proxy#1774)
* Rename HTTPRoutePermit to HttpRoutePermit (linkerd/linkerd2-proxy#1779)
* retry gRPC requests are immediately terminated by trailers (linkerd/linkerd2-proxy#1706)
* inbound: Record policy metrics for opaque-transport connections (linkerd/linkerd2-proxy#1780)
* build(deps): bump tj-actions/changed-files from 23 to 23.1 (linkerd/linkerd2-proxy#1782)
* build(deps): bump derive_arbitrary from 1.1.2 to 1.1.3 (linkerd/linkerd2-proxy#1783)
* build(deps): bump arbitrary from 1.1.2 to 1.1.3 (linkerd/linkerd2-proxy#1784)
* inbound: Record TCP metrics for forwarded TLS connections (linkerd/linkerd2-proxy#1785)
* inbound: Cleanup in preparation for route policies #1781 (linkerd/linkerd2-proxy#1786)
* Add HTTP route matchers to support the Gateway API (linkerd/linkerd2-proxy#1787)
* build(deps): bump unicode-normalization from 0.1.19 to 0.1.20 (linkerd/linkerd2-proxy#1789)
* build(deps): bump linked-hash-map from 0.5.4 to 0.5.6 (linkerd/linkerd2-proxy#1790)
* build(deps): bump smallvec from 1.8.0 to 1.8.1 (linkerd/linkerd2-proxy#1791)
* build(deps): bump jemalloc-sys from 0.5.0+5.3.0 to 0.5.1+5.3.0-patched (linkerd/linkerd2-proxy#1792)
* Introduce per-route authorization policies (linkerd/linkerd2-proxy#1781)
* inbound: Add a header-modification route filter (linkerd/linkerd2-proxy#1793)
* docs: update justfile man page link (linkerd/linkerd2-proxy#1794)

Signed-off-by: Oliver Gould <[email protected]>
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.

2 participants