Skip to content
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

Merged
merged 1 commit into from
Nov 9, 2021
Merged

fix(kuma-cp) ensure HTTP router filter ordering #3082

merged 1 commit into from
Nov 9, 2021

Conversation

jpeach
Copy link
Contributor

@jpeach jpeach commented Nov 4, 2021

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

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

Backwards compatibility

  • Add backport-to-stable label if the code is backwards compatible. Otherwise, list breaking changes.

@jpeach jpeach requested a review from a team as a code owner November 4, 2021 08:27
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>
Copy link
Contributor

@michaelbeaumont michaelbeaumont left a 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?

@jpeach
Copy link
Contributor Author

jpeach commented Nov 6, 2021

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.

@jpeach jpeach merged commit 11e3b32 into kumahq:master Nov 9, 2021
@jpeach jpeach deleted the fix/force-router-order branch November 9, 2021 02:01
mergify bot pushed a commit that referenced this pull request Nov 9, 2021
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)
jpeach added a commit that referenced this pull request Nov 9, 2021
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>
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.

None yet

3 participants