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

Envoy rate limit descriptor fix #11153

Merged

Conversation

karbon0x
Copy link
Contributor

@karbon0x karbon0x commented May 11, 2020

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

Description: It resolves - #10124 indirectly by adding an extra config flag to RequestHeaders through which it is possible for descriptors to be sent on a partial match
Risk Level: low - optional feature
Testing: unit tests added
Docs Changes: Added
Release Notes: Added
[Optional Fixes #Issue] Fixes #10124
[Optional Deprecated:]

Rohan Seth added 7 commits May 11, 2020 09:56
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
@karbon0x
Copy link
Contributor Author

Need to add associated documentation changes for the new configuration option. Opening PR so that @ramaraochavali can view it.

@karbon0x karbon0x marked this pull request as draft May 11, 2020 23:07
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/.

🐱

Caused by: #11153 was synchronize by rohan07.

see: more, trace.

@karbon0x karbon0x marked this pull request as ready for review May 13, 2020 06:54
@karbon0x karbon0x marked this pull request as draft May 13, 2020 06:55
@@ -1385,6 +1385,10 @@ message RateLimit {

// The key to use in the descriptor entry.
string descriptor_key = 2 [(validate.rules).string = {min_bytes: 1}];

// The optional parameter which determines if the RLS is called if a request
Copy link
Contributor

Choose a reason for hiding this comment

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

If set to true, Envoy skips the descriptor while calling rate limiting service when header is not present in the request. Defaults to false, which skips calling rate limiting service if this header is not present in the request.

@@ -38,10 +38,14 @@ bool RequestHeadersAction::populateDescriptor(const Router::RouteEntry&,
const Http::HeaderMap& headers,
const Network::Address::Instance&) const {
const Http::HeaderEntry* header_value = headers.get(header_name_);
if (!header_value) {
if (!header_value && !skip_if_absent_) {
Copy link
Contributor

@ramaraochavali ramaraochavali May 13, 2020

Choose a reason for hiding this comment

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

nit: Simplify it like this and add a comment

  if (!header_value) {
    return skip_if_absent_;
  }

@@ -366,6 +366,94 @@ TEST_F(RateLimitPolicyEntryTest, RequestHeaders) {
testing::ContainerEq(descriptors_));
}

// Validate that a descriptor is added if at least one request header has value.
TEST_F(RateLimitPolicyEntryTest, RequestHeadersPartialMatchWithSkipIfAbsent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

/s/RequestHeadersPartialMatchWithSkipIfAbsent/RequestHeadersWithSkipIfAbsent

testing::ContainerEq(descriptors_));
}

TEST_F(RateLimitPolicyEntryTest, RequestHeadersPartialMatchWithoutSkipIfAbsent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

/s/RequestHeadersPartialMatchWithoutSkipIfAbsent/RequestHeadersWithDefaultSkipIfAbsent and add a comment above the test

testing::ContainerEq(descriptors_));
}

TEST_F(RateLimitPolicyEntryTest, RequestHeadersMatchDefaultSkipIfAbsent) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed

EXPECT_TRUE(descriptors_.empty());
}

TEST_F(RateLimitPolicyEntryTest, RequestHeadersCompleteMatch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This also should have been tested already

@ramaraochavali
Copy link
Contributor

Rohan Seth added 3 commits May 13, 2020 01:11
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
@karbon0x karbon0x marked this pull request as ready for review May 13, 2020 09:23
@@ -39,10 +39,11 @@ Changes
* network filters: added a :ref:`rocketmq proxy filter <config_network_filters_rocketmq_proxy>`.
* prometheus stats: fix the sort order of output lines to comply with the standard.
* request_id: added to :ref:`always_set_request_id_in_response setting <envoy_v3_api_field_extensions.filters.network.http_connection_manager.v3.HttpConnectionManager.always_set_request_id_in_response>`
to set :ref:`x-request-id <config_http_conn_man_headers_x-request-id>` header in response even if
to set :ref:`x-request-id <config_http_conn_man_headers_x-request-id>` header in response even if skip_if_absent
Copy link
Contributor

Choose a reason for hiding this comment

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

not needed change looks like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, pushing the fix, accidental change

Rohan Seth added 2 commits May 13, 2020 02:35
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.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.

API changes LGTM modulo two tiny nits.

@@ -1385,6 +1385,11 @@ message RateLimit {

// The key to use in the descriptor entry.
string descriptor_key = 2 [(validate.rules).string = {min_bytes: 1}];

// If set to true, Envoy skips the descriptor while calling rate limiting service
// when header is not present in the request. Defaults to false, which skips calling
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// when header is not present in the request. Defaults to false, which skips calling
// when header is not present in the request. By default this skips calling

i.e. it's redundant to say that the default of a primitive proto3 type is false, but your description of the actual behavior is very helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, @htuch! Pushed the changes as you suggested! Thanks!

@@ -43,6 +43,7 @@ Changes
tracing is not forced.
* router: allow retries of streaming or incomplete requests. This removes stat `rq_retry_skipped_request_not_complete`.
* router: allow retries by default when upstream responds with :ref:`x-envoy-overloaded <config_http_filters_router_x-envoy-overloaded_set>`.
* router: allow Rate Limiting service to be called in case of missing request header for a descriptor if the :ref:`skip_if_absent <envoy_v3_api_field_config.route.v3.RateLimit.Action.RequestHeaders.skip_if_absent>` field is set to true.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Rate Limiting SErvice

Signed-off-by: Rohan Seth <rohan@Rohans-MacBook-Pro.local>
@karbon0x karbon0x force-pushed the envoy-rate-limit-descriptor-fix branch from 26eebbf to 9cfaeaa Compare May 18, 2020 20:15
@mattklein123
Copy link
Member

@rohan07 please never force push. It makes reviews much more difficult. Thanks!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks one more comment.

/wait

@@ -38,10 +38,11 @@ bool RequestHeadersAction::populateDescriptor(const Router::RouteEntry&,
const Http::HeaderMap& headers,
const Network::Address::Instance&) const {
const Http::HeaderEntry* header_value = headers.get(header_name_);

// If header is not present and skip_if_absent_ is true, ignore the descriptor
Copy link
Member

Choose a reason for hiding this comment

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

This comment is still not correct. Returning has no bearing on whether skip_if_absent_ is true?

@mattklein123
Copy link
Member

Thanks please merge master and force push to fix DCO.

/wait

@karbon0x
Copy link
Contributor Author

Apologies @mattklein123 - My previous force push was also because of the DCO. I was experiencing some performance issues with my old machine so had to get a new one.

@karbon0x karbon0x force-pushed the envoy-rate-limit-descriptor-fix branch 3 times, most recently from c7c58a2 to a83afa4 Compare May 20, 2020 19:28
Signed-off-by: Rohan Seth <rohan@Rohans-MacBook-Pro.local>
@karbon0x karbon0x force-pushed the envoy-rate-limit-descriptor-fix branch from ca3ca83 to 281b9e4 Compare May 20, 2020 21:07
Rohan Seth added 3 commits May 20, 2020 14:14
…descriptor-fix

Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks!

@karbon0x
Copy link
Contributor Author

Hi @mattklein123 - Apologies again, it wasn't allowing me to sign off on my previous commit using my new machine for some reason, it worked from my previous machine. Thanks for your help!

@karbon0x
Copy link
Contributor Author

Hi @mattklein123 - I am seeing some of the other PR's which are open facing the same issue with circleci/coverage failing (with 96.7%, lower than the 97% threshold). I believe during my earlier commits, the particular test was passing. Can you please advise the future steps I should take?

@ramaraochavali
Copy link
Contributor

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #11153 (comment) was created by @ramaraochavali.

see: more, trace.

…descriptor-fix

Signed-off-by: Rohan Seth <rohan.seth@salesforce.com>
@mattklein123 mattklein123 merged commit 77e436f into envoyproxy:master May 21, 2020
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.

Envoy skips calling rate limiting service when request header is not present
4 participants