-
Notifications
You must be signed in to change notification settings - Fork 327
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
fix(kuma-cp) ensure HTTP router filter ordering #3082
Conversation
The HTTP connection manager filter chain must terminate with the router filter. Each time a filter is added, the configurer needs to be careful to prepend itself to the chain to ensure that the router remains last. This makes it hard to reason about the ordering of filters, since it will be the reverse of the configurer application order, and it makes it unnecessarily tricky to write new configurers. So the easiest approach is for the builder to simply ensure that there is always a router filter appended when it builds the filter chain. Since it is a filter chain builder, it's reasonable for it to know something about filter chain semantics. We might need to do something more complicated if we ever need to set any fields in the router, but for now it seems reasonable to stick with simplicity. Signed-off-by: James Peach <james.peach@konghq.com>
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.
// Ensure there is always an HTTP router terminating the filter chain.
Is there a test that can be added that is fixed by this PR?
Not really. I made this change because I got burned by adding a new filter, and the current behavior is brain-bending. If the order is wrong, envoy will refuse the payload, so it's tested in that sense. |
The HTTP connection manager filter chain must terminate with the router filter. Each time a filter is added, the configurer needs to be careful to prepend itself to the chain to ensure that the router remains last. This makes it hard to reason about the ordering of filters, since it will be the reverse of the configurer application order, and it makes it unnecessarily tricky to write new configurers. So the easiest approach is for the builder to simply ensure that there is always a router filter appended when it builds the filter chain. Since it is a filter chain builder, it's reasonable for it to know something about filter chain semantics. We might need to do something more complicated if we ever need to set any fields in the router, but for now it seems reasonable to stick with simplicity. Signed-off-by: James Peach <james.peach@konghq.com> (cherry picked from commit 11e3b32)
The HTTP connection manager filter chain must terminate with the router filter. Each time a filter is added, the configurer needs to be careful to prepend itself to the chain to ensure that the router remains last. This makes it hard to reason about the ordering of filters, since it will be the reverse of the configurer application order, and it makes it unnecessarily tricky to write new configurers. So the easiest approach is for the builder to simply ensure that there is always a router filter appended when it builds the filter chain. Since it is a filter chain builder, it's reasonable for it to know something about filter chain semantics. We might need to do something more complicated if we ever need to set any fields in the router, but for now it seems reasonable to stick with simplicity. Signed-off-by: James Peach <james.peach@konghq.com> (cherry picked from commit 11e3b32) Co-authored-by: James Peach <james.peach@konghq.com>
Summary
The HTTP connection manager filter chain must terminate with the router
filter. Each time a filter is added, the configurer needs to be careful
to prepend itself to the chain to ensure that the router remains last.
This makes it hard to reason about the ordering of filters, since it
will be the reverse of the configurer application order, and it makes
it unnecessarily tricky to write new configurers.
So the easiest approach is for the builder to simply ensure that there
is always a router filter appended when it builds the filter chain.
Since it is a filter chain builder, it's reasonable for it to know
something about filter chain semantics. We might need to do something
more complicated if we ever need to set any fields in the router, but
for now it seems reasonable to stick with simplicity.
Full changelog
N/A
Issues resolved
N/A
Documentation
N/A
Testing
Backwards compatibility
backport-to-stable
label if the code is backwards compatible. Otherwise, list breaking changes.