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

set_filter_state: enable per-route configuration override #37507

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

howardjohn
Copy link
Contributor

Commit Message: set_filter_state: enable per-route configuration override
Additional Description:
This extends this filter to support usage in route configuration. When present, both the listener and route level settings are applied (listener first, then route).

Risk Level: Low
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

@wbpcode wbpcode self-assigned this Dec 5, 2024
@wbpcode
Copy link
Member

wbpcode commented Dec 5, 2024

@kyessenov will be OOO for a while, fine, let me review this.

@wbpcode
Copy link
Member

wbpcode commented Dec 6, 2024

I think some tests for this new feature is necessary.

/wait

@howardjohn
Copy link
Contributor Author

TBH I have no idea how to write tests, this simple change already took me nearly 10hrs to understanding

@wbpcode
Copy link
Member

wbpcode commented Dec 7, 2024

TBH I have no idea how to write tests, this simple change already took me nearly 10hrs to understanding

😂 but it's required or we cannot merge this. Is there anyone is familiar to envoy in your colleagues?

Comment on lines +24 to +32
config_.get()->updateFilterState({&headers}, decoder_callbacks_->streamInfo());

// If configured, apply route level configuration next.
auto per_route_config =
Http::Utility::resolveMostSpecificPerFilterConfig<Filters::Common::SetFilterState::Config>(
decoder_callbacks_);
if (per_route_config) {
per_route_config->updateFilterState({&headers}, decoder_callbacks_->streamInfo());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you run both, typically a route level config will override the listener level

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking it would be nice to have common listener level ones and then have additional route specific ones. You can override by applying both (route is last so it wins).

We do have this use case - but it could also be done by just copying the listener ones into every route of course.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say in that case you should have explicit options most likely, as in override, merge, etc. Also acceptable at first of course to just say there's only one behavior, but this would be different from most filters today afaik

@howardjohn
Copy link
Contributor Author

@wbpcode @EItanya I was able to add a test, thanks for the help

@howardjohn howardjohn force-pushed the sfs/support-per-route branch 2 times, most recently from beb9ae9 to 7d55bb1 Compare December 11, 2024 21:32
This extends this filter to support usage in route configuration. When
present, both the listener and route level settings are applied
(listener first, then route).

Signed-off-by: John Howard <[email protected]>
@howardjohn howardjohn force-pushed the sfs/support-per-route branch from 7d55bb1 to 5c8a97f Compare December 11, 2024 23:10
Signed-off-by: John Howard <[email protected]>
@howardjohn howardjohn force-pushed the sfs/support-per-route branch from 5c8a97f to 46a6a0c Compare December 11, 2024 23:53
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.

3 participants