-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
config: support determine terminal filter at runtime #15803
Conversation
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> add a test Signed-off-by: qinggniq <[email protected]> add test Signed-off-by: qinggniq <[email protected]> add test Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]> fix typo Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
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.
Thanks this makes sense, just some questions around how we'll handle the dynamic case
@@ -32,11 +32,14 @@ class FilterConfigProviderManager { | |||
* @param filter_config_name the filter config resource name. | |||
* @param factory_context is the context to use for the filter config provider. | |||
* @param stat_prefix supplies the stat_prefix to use for the provider stats. | |||
* @param last_filter_in_current_config indicate the filter position at filter chain |
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.
maybe something like indicates whether this filter is the last filter in the configured chain
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.
fixed.
*/ | ||
virtual FilterConfigProviderPtr createDynamicFilterConfigProvider( | ||
const envoy::config::core::v3::ExtensionConfigSource& config_source, | ||
const std::string& filter_config_name, Server::Configuration::FactoryContext& factory_context, | ||
const std::string& stat_prefix) PURE; | ||
const std::string& stat_prefix, bool last_filter_in_current_config, |
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.
maybe just last_filter
? or last_filter_in_filter_chain
? not sure what "current" is referring to
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.
last_filter_in_filter_chain
better.
@@ -64,6 +69,12 @@ void DynamicFilterConfigProviderImpl::onConfigUpdate(Envoy::Http::FilterFactoryC | |||
this->current_config_ = config; | |||
}); | |||
} | |||
void DynamicFilterConfigProviderImpl::validateTermianlFilter(const std::string& name, |
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.
typo in name
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.
fixed.
@@ -106,7 +117,7 @@ void FilterConfigSubscription::onConfigUpdate( | |||
throw EnvoyException(fmt::format( | |||
"Unexpected number of resources in ExtensionConfigDS response: {}", resources.size())); | |||
} | |||
const auto& filter_config = dynamic_cast<const envoy::config::core::v3::TypedExtensionConfig&>( | |||
auto& filter_config = dynamic_cast<const envoy::config::core::v3::TypedExtensionConfig&>( |
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.
why remove the const here? we cast to a const ref
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.
sorry, did not notice.
@@ -121,6 +129,7 @@ class FilterConfigSubscription | |||
absl::optional<Envoy::Http::FilterFactoryCb> last_config_{absl::nullopt}; | |||
std::string last_type_url_; | |||
std::string last_version_info_; | |||
envoy::config::core::v3::TypedExtensionConfig last_filter_config_; |
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.
I think we intentionally avoid storing the entire filter config, can we just track whether the last filter passed the terminal filter check?
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.
Yes, we only need it_terminal_filter
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Can you merge main to resolve conflicts and look at getting CI green? Thanks |
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
@snowp I think the remain ci flakes is due to not update https://github.com/envoyproxy/envoy-filter-example, should I give a pr to that repo? |
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.
Thanks, just a couple comments
CI seems to still be broken
/wait
@@ -353,7 +355,6 @@ TEST_F(FilterConfigDiscoveryImplTest, DualProviders) { | |||
TEST_F(FilterConfigDiscoveryImplTest, DualProvidersInvalid) { | |||
InSequence s; | |||
setup(); | |||
auto provider2 = createProvider("foo", true, false); |
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.
is this intentional?
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.
By mistake.
@@ -600,6 +608,28 @@ TEST_P(ExtensionDiscoveryIntegrationTest, BasicFailWithoutDefault) { | |||
EXPECT_EQ("500", response->headers().getStatusValue()); | |||
} | |||
|
|||
// test when terminal filter config not put at last config position |
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.
nit: proper sentence, proper casing + punctuation
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.
fixed.
@@ -8,4 +8,5 @@ message SetResponseCodeFilterConfig { | |||
string prefix = 1; | |||
uint32 code = 2 [(validate.rules).uint32 = {lt: 600 gte: 200}]; | |||
string body = 3; | |||
bool is_terminal_filter = 4; |
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.
I would do this in a different test filter instead of overloading the existing one
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.
reset.
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
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.
Thanks this LGTM. Can you check CI? I think the asan/tsan ones are legit
Oh actually no those are the filter example ones you mentioned, let me look into how we can fix this |
@qinggniq Can you make a PR to envoy-filter-example and point the SHA in ci/filter_example_setup.sh to the commit in the PR? That should let this PR test against the envoy-filter-example PR |
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
/retest |
Retrying Azure Pipelines: |
Signed-off-by: qinggniq <[email protected]>
The failures of ci |
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
/retest |
1 similar comment
/retest |
Retrying Azure Pipelines: |
Retrying Azure Pipelines: |
@snowp all cis are green, waiting for envoyproxy/envoy-filter-example#144 merged. I will change the commit SHA and URL at ci/setup_example_filter.sh to the latest commit. |
I merged the filter example PR, can you update this to use the new commit and we'll get this landed? Thanks |
Signed-off-by: qinggniq <[email protected]>
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.
Thanks!
Currently we validate terminal filter before getting real protobuf message, now envoy can determine a filter whether is a terminal filter base on the protobuf message. Signed-off-by: qinggniq <[email protected]> Signed-off-by: Gokul Nair <[email protected]>
fix #15565.
Currently we validate terminal filter before getting real protobuf message, now envoy can determine a filter whether is a terminal filter base on the protobuf message.
Commit Message: config: support determine terminal filter at runtime
Additional Description:
Risk Level: Low
Testing: TBD
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]