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

network: Enable the Kill Request filter to honor Route-level configur… #14944

Merged
merged 8 commits into from
Feb 18, 2021

Conversation

xiaobinxbw
Copy link
Contributor

network: Enable the Kill Request filter to honor Route-level configuration. (#14929)

Signed-off-by: Tommy Wang xiaobinwang@google.com

For an explanation of how to fill out the fields, please see the relevant section
in PULL_REQUESTS.md

Commit Message:
Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Deprecated:]
[Optional API Considerations:]

…ation. (envoyproxy#14929)

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
@repokitteh-read-only
Copy link

Hi @xiaobinxbw, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #14944 was opened by xiaobinxbw.

see: more, trace.

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
htuch
htuch previously approved these changes Feb 5, 2021
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -29,6 +37,20 @@ Http::FilterHeadersStatus KillRequestFilter::decodeHeaders(Http::RequestHeaderMa
return Http::FilterHeadersStatus::Continue;
}

// Route-level configuration overrides filter-level configuration.
if (decoder_callbacks_->route() && decoder_callbacks_->route()->routeEntry()) {
const std::string& name = Extensions::HttpFilters::HttpFilterNames::get().KillRequest;
Copy link
Member

Choose a reason for hiding this comment

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

I think we eventually want to match with the actual name used in the filter instantiation, but this hasn't been fixed Envoy-wide to my knowledge (#12575).

@xiaobinxbw
Copy link
Contributor Author

xiaobinxbw commented Feb 5, 2021 via email

@htuch
Copy link
Member

htuch commented Feb 5, 2021

@xiaobinxbw the coverage CI failure looks legit. Is there any way to bump test coverage?

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
@xiaobinxbw
Copy link
Contributor Author

Hey Harvey,

I've added another use case which should cover the branches in my added code. I am not sure why it's still complaining about the coverage. Is there any way I can generate a coverage report? Sorry for the dumb question as it's my very first oss work :)

btw, i accidentally closed the pull request and reopened it. I will need your help with the approval again.

Thanks,
Tommy

@@ -102,6 +102,20 @@ TEST_F(KillRequestFilterTest,
EXPECT_DEATH(filter_->decodeHeaders(request_headers_, false), "");
}

TEST_F(KillRequestFilterTest,
KillRequestDisabledWhenIsKillRequestEnabledReturnsFalseFromRouteLevelConfiguration) {
Copy link
Member

Choose a reason for hiding this comment

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

These names for tests are kind of unreadably long. Can you replace them with a shorter name and then add a single line // comment above providing the intuition that is currently captured in the name? Here and elsewhere in these tests. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@htuch
Copy link
Member

htuch commented Feb 7, 2021

@xiaobinxbw you can see the coverage report at https://storage.googleapis.com/envoy-pr/f7c1716/coverage/source/extensions/filters/http/kill_request/kill_request_filter.cc.gcov.html, which you get to by clicking through to the CI details and selecting the GCS link under "linux_x64 coverage" -> "Upload coverage report". You can see it's missing functional coverage of the behaviors in this PR.

To generate reports locally, follow https://github.com/envoyproxy/envoy/blob/main/bazel/README.md#coverage-builds.

@htuch htuch added the waiting label Feb 7, 2021
@xiaobinxbw
Copy link
Contributor Author

@xiaobinxbw you can see the coverage report at https://storage.googleapis.com/envoy-pr/f7c1716/coverage/source/extensions/filters/http/kill_request/kill_request_filter.cc.gcov.html, which you get to by clicking through to the CI details and selecting the GCS link under "linux_x64 coverage" -> "Upload coverage report". You can see it's missing functional coverage of the behaviors in this PR.

To generate reports locally, follow https://github.com/envoyproxy/envoy/blob/main/bazel/README.md#coverage-builds.

Thanks a lot for the instructions, Harvey.

However, the two test cases actually covers the red part in the report, and i am not sure why the coverage report doesn't think this way. My guess is that the decoder_filter_callbacks_.route_->route_entry_ call is mocked, and the actually killing part (raise(SIGABRT);) is hijacked?

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
@xiaobinxbw
Copy link
Contributor Author

Hey Harvey,

Just a note that i've run the dependency check locally with the command "ci/run_envoy_docker.sh 'ci/do_ci.sh deps'", and it succeeded. I don't think the latest test comment change could break the dependencies either. I haven't found a way to re-trigger this presubmit check without committing a code change, though.

Thanks,
Tommy

@htuch
Copy link
Member

htuch commented Feb 10, 2021

@xiaobinxbw are you sure those paths are executed? I.e. verified with log messages and the tests. There may be some coverage corner cases with death tests IIRC, but just want to check you have validated that those paths are taken in the tests you describe.

@xiaobinxbw
Copy link
Contributor Author

xiaobinxbw commented Feb 10, 2021 via email

Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM modulo comments and adding a coverage exception to https://github.com/envoyproxy/envoy/blob/main/test/per_file_coverage.sh#L5. I'm pretty sure that there was some issue around coverage and death tests from ages ago but I can't recall (maybe @dnoe remembers).

return kill_request_filter_headers_;
}

const envoy::type::v3::FractionalPercent getProbability() const {
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit weird. Why not just make return type const envoy::type::v3::FractionalPercent& and skip the move?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

route_entry->mostSpecificPerFilterConfigTyped<KillSettings>(name);

if (per_route_kill_settings) {
envoy::type::v3::FractionalPercent probability = per_route_kill_settings->getProbability();
Copy link
Member

Choose a reason for hiding this comment

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

Nit: const envoy::type::v3::FractionalPercent probability = = ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
@htuch
Copy link
Member

htuch commented Feb 17, 2021

@xiaobinxbw looks good, can you get CI format to pass? Thanks. You will also need to add the coverage exception I mention in #14944 (review)

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
@xiaobinxbw
Copy link
Contributor Author

@xiaobinxbw looks good, can you get CI format to pass? Thanks. You will also need to add the coverage exception I mention in #14944 (review)

@htuch Done!

Signed-off-by: Tommy Wang <xiaobinwang@google.com>
Signed-off-by: Tommy Wang <xiaobinwang@google.com>
Copy link
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@htuch htuch merged commit b2f3a11 into envoyproxy:main Feb 18, 2021
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.

2 participants