Skip to content

local ratelimit support virtualhost config#22895

Merged
mattklein123 merged 13 commits into
envoyproxy:mainfrom
StarryVae:local_ratelimit_vh
Sep 16, 2022
Merged

local ratelimit support virtualhost config#22895
mattklein123 merged 13 commits into
envoyproxy:mainfrom
StarryVae:local_ratelimit_vh

Conversation

@StarryVae
Copy link
Copy Markdown
Contributor

Signed-off-by: wangkai19 wangkai19@corp.netease.com

Commit Message: local ratelimit support virtualhost config
Additional Description: N/A
Risk Level: low
Testing: ut
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #22895 was opened by StarryVae.

see: more, trace.

@StarryVae
Copy link
Copy Markdown
Contributor Author

issue #22793 PTAL, thanks. @wbpcode @mattklein123

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!
Left a high-level API comment.
I think that the code that handles this configuration should also be shared (I'm assuming that if one adds any other enum value, or updates the code, this should be reflected for both the per-route and the local rate-limit).

}

// Specifies if the local rate limit filter should include the virtual host rate limits.
VhRateLimitsOptions vh_rate_limits = 13 [(validate.rules).enum = {defined_only: true}];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMHO the enum from envoy.extensions.filters.http.ratelimit.v3 should be used.

It would have been better to move this enum to some common location, but unfortunately I think it will break the current API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, thanks, i will use envoy.extensions.filters.http.ratelimit.v3 instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

x1b[0m/build/tmp/_bazel_envoybuild/b570b5ccd0454dc9af9f65ab1833764d/external/envoy_api/envoy/extensions/filters/http/local_ratelimit/v3/BUILD:7:18: GoCompilePkg external/envoy_api/envoy/extensions/filters/http/local_ratelimit/v3/pkg_go_proto.a failed: (Exit 1): builder failed: error executing command (from target @envoy_api//envoy/extensions/filters/http/local_ratelimit/v3:pkg_go_proto) bazel-out/k8-opt-exec-2B5CBBC6/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src ... (remaining 85 arguments skipped)\n\nUse --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging\nbazel-out/k8-fastbuild/bin/external/envoy_api/envoy/extensions/filters/http/local_ratelimit/v3/pkg_go_proto_/github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3/local_rate_limit.pb.validate.go:43:6: undefined: "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ratelimit/v3".XRateLimitHeadersRFCVersion\nbazel-out/k8-fastbuild/bin/external/envoy_api/envoy/extensions/filters/http/local_ratelimit/v3/pkg_go_proto_/github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3/local_rate_limit.pb.validate.go:343:11: assignment mismatch: 2 variables but 1 value\nbazel-out/k8-fastbuild/bin/external/envoy_api/envoy/extensions/filters/http/local_ratelimit/v3/pkg_go_proto_/github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3/local_rate_limit.pb.validate.go:343:14: undefined: "github.com/envoyproxy/go-control-plane/envoy/extensions/common/ratelimit/v3".RateLimitPerRoute_VhRateLimitsOptions_name\ncompilepkg: error running subcommand external/go_sdk/pkg/tool/linux_amd64/compile: exit status 2\n\x1b[32mINFO: \x1b[0mElapsed time: 189.979s, Critical Path: 20.43s\n\x1b[32mINFO: \x1b[0m1278 processes: 24 internal, 1254 processwrapper-sandbox.\n\x1b[31m\x1b[1mFAILED:\x1b[0m Build did NOT complete successfully\n\x1b[31m\x1b[1mFAILED:\x1b[0m Build did NOT complete successfully\n\x1b[0m'

@adisuissa i tried use envoy.extensions.filters.http.ratelimit.v3, but the bazel.api check failed, detailed errors are above. it seems that the go_package name of envoy.extensions.common.ratelimit.v3 and envoy.extensions.filters.http.ratelimit.v3 conflict?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, sorry about that.
I guess the way to get around this is to do something similar to what was done for XRateLimitHeadersRFCVersion (context in PR #18157):

  1. Copy the enum into common.
  2. In the local ratelimit use the enum from common.
  3. Add comments for the definition and usage of the enum (similar to this and this).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, thanks!

@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Aug 31, 2022

Please check the CI, thanks.

/wait

Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@StarryVae
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

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

🐱

Caused by: a #22895 (comment) was created by @StarryVae.

see: more, trace.

@StarryVae
Copy link
Copy Markdown
Contributor Author

WARNING: Download from https://github.com/antlr/antlr4/archive/v4.10.1.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
ERROR: An error occurred during the fetch of repository 'antlr4_runtimes':

this blocks the pipeline.

@StarryVae
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

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

🐱

Caused by: a #22895 (comment) was created by @StarryVae.

see: more, trace.

@StarryVae
Copy link
Copy Markdown
Contributor Author

@wbpcode CI is passed, PTAL, thanks.

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for this contribution and some comments are added.


switch (vh_rate_limit_option) {
case VhRateLimitOptions::Ignore:
break;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: maybe use return here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thanks.

Comment on lines +245 to +246
default:
PANIC("not reached");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: PANIC_DUE_TO_CORRUPT_ENUM could be used here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thanks.

Comment on lines +282 to +292
switch (specific_per_route_config->virtualHostRateLimits()) {
case envoy::extensions::common::ratelimit::v3::INCLUDE:
vh_rate_limits_ = VhRateLimitOptions::Include;
break;
case envoy::extensions::common::ratelimit::v3::IGNORE:
vh_rate_limits_ = VhRateLimitOptions::Ignore;
break;
case envoy::extensions::common::ratelimit::v3::OVERRIDE:
default:
vh_rate_limits_ = VhRateLimitOptions::Override;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

use PANIC_ON_PROTO_ENUM_SENTINEL_VALUES here to avoid the default usage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thanks. @wbpcode

Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

/lgtm api

@repokitteh-read-only repokitteh-read-only Bot removed the api label Sep 6, 2022
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Sep 8, 2022

It's looks good overall for me. And please merge main again to fix the CI. Thanks.

/wait

Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@repokitteh-read-only repokitteh-read-only Bot added api and removed waiting labels Sep 8, 2022
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Sep 13, 2022

/wait

Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Copy link
Copy Markdown
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

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

/lgtm api

@StarryVae
Copy link
Copy Markdown
Contributor Author

@wbpcode CI is passed, PTAL again, thanks.

wbpcode
wbpcode previously approved these changes Sep 16, 2022
Copy link
Copy Markdown
Member

@wbpcode wbpcode 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. Defer this to @mattklein123 for final pass.

Copy link
Copy Markdown
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 LGTM. Can you add a release note please?

/wait

Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@StarryVae
Copy link
Copy Markdown
Contributor Author

Thanks LGTM. Can you add a release note please?

/wait

done, thanks.

Comment thread changelogs/current.yaml Outdated
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Sep 16, 2022

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Check envoy-presubmit isn't fully completed, but will still attempt retrying.
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #22895 (comment) was created by @wbpcode.

see: more, trace.

@StarryVae
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

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

🐱

Caused by: a #22895 (comment) was created by @StarryVae.

see: more, trace.

@StarryVae
Copy link
Copy Markdown
Contributor Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

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

🐱

Caused by: a #22895 (comment) was created by @StarryVae.

see: more, trace.

Copy link
Copy Markdown
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!

@mattklein123 mattklein123 merged commit 53837e6 into envoyproxy:main Sep 16, 2022
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.

4 participants