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

config: support determine terminal filter at runtime #15803

Merged
merged 29 commits into from
Apr 19, 2021
Merged

Conversation

qinggniq
Copy link
Contributor

@qinggniq qinggniq commented Apr 1, 2021

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:]

qinggniq and others added 6 commits March 30, 2021 17:38
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]>
qinggniq added 2 commits April 1, 2021 18:32
Signed-off-by: qinggniq <[email protected]>

fix typo

Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Copy link
Contributor

@snowp snowp left a 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
Copy link
Contributor

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

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

typo in name

Copy link
Contributor Author

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&>(
Copy link
Contributor

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

Copy link
Contributor Author

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_;
Copy link
Contributor

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?

Copy link
Contributor Author

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

qinggniq added 4 commits April 2, 2021 13:28
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
@snowp
Copy link
Contributor

snowp commented Apr 5, 2021

Can you merge main to resolve conflicts and look at getting CI green? Thanks

@qinggniq
Copy link
Contributor Author

qinggniq commented Apr 6, 2021

@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?

Copy link
Contributor

@snowp snowp left a 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this intentional?

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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;
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 do this in a different test filter instead of overloading the existing one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reset.

@qinggniq qinggniq requested a review from snowp April 14, 2021 09:05
snowp
snowp previously approved these changes Apr 14, 2021
Copy link
Contributor

@snowp snowp left a 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

@snowp
Copy link
Contributor

snowp commented Apr 14, 2021

Oh actually no those are the filter example ones you mentioned, let me look into how we can fix this

@snowp
Copy link
Contributor

snowp commented Apr 14, 2021

@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

@qinggniq
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15803 (comment) was created by @qinggniq.

see: more, trace.

@qinggniq
Copy link
Contributor Author

The failures of ci asan and tsan seem due to #15972 (comment).

Signed-off-by: qinggniq <[email protected]>
Signed-off-by: qinggniq <[email protected]>
@qinggniq
Copy link
Contributor Author

/retest

1 similar comment
@qinggniq
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15803 (comment) was created by @qinggniq.

see: more, trace.

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #15803 (comment) was created by @qinggniq.

see: more, trace.

@qinggniq
Copy link
Contributor Author

@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.

@snowp
Copy link
Contributor

snowp commented Apr 19, 2021

I merged the filter example PR, can you update this to use the new commit and we'll get this landed? Thanks

Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks!

@snowp snowp merged commit e1935de into envoyproxy:main Apr 19, 2021
@qinggniq qinggniq deleted the main branch April 20, 2021 08:15
gokulnair pushed a commit to gokulnair/envoy that referenced this pull request May 6, 2021
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]>
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.

Question: Is there are any way to determine whether is a terminal filter at runtime?
3 participants