-
Notifications
You must be signed in to change notification settings - Fork 583
feat: support both local and global ratelimit simultaneously #7334
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7334 +/- ##
==========================================
+ Coverage 72.34% 72.38% +0.03%
==========================================
Files 231 231
Lines 33896 33918 +22
==========================================
+ Hits 24521 24550 +29
+ Misses 7614 7607 -7
Partials 1761 1761 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cd2f2fa to
5cb3b15
Compare
| if match.Distinct { | ||
| // For distinct matches, we only check if the header exists using the RequestHeaders action. | ||
| descriptorKey := getRouteRuleDescriptor(rIdx, mIdx) | ||
| descriptorKey := fmt.Sprintf("local_%s", getRouteRuleDescriptor(rIdx, mIdx)) |
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.
imo not needed, since these are applied to different filters, prefer minimal changes to enable this
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, I misunderstood 🙏 I’ve reverted it.
| return patchRouteWithRateLimitOnTypedFilterConfig(route, rateLimits, irRoute) | ||
| } | ||
| xdsRouteAction.RateLimits = rateLimits | ||
| xdsRouteAction.RateLimits = append(xdsRouteAction.RateLimits, rateLimits...) |
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 needed
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, append operation is necessary to avoid overwriting the local rate limit config.
https://github.com/envoyproxy/gateway/blob/main/internal/xds/translator/local_ratelimit.go#L139
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 an existing bug or related to this PR ?
cc @zhaohuabing
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.
this is related to this PR.
I believe there was no issue before because we had only used either local or global, not both.
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.
the code flow for local looks like its different
| rateLimits, descriptors := buildRouteLocalRateLimits(local) |
vs global
gateway/internal/xds/translator/ratelimit.go
Line 212 in cb8a7ca
| global := route.Traffic.RateLimit.Global |
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.
avoid overwriting the local rate limit config.
sorry, my word make mislead.
There’s no issue converting both the local and global configurations from irRoute to routev3.RateLimit.
However, since both converted routev3.RateLimit are set on the same xdsRouteAction, if we don’t append them, only the later processed (global) routev3.RateLimit will take effect.
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.
ah in that case, we need to bring back the local_ prefix to ensure uniqueness in descriptors, my bad
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
9e40480 to
402db53
Compare
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
Signed-off-by: kkk777-7 <kota.kimura0725@gmail.com>
What this PR does / why we need it:
Support both local and global ratelimit in BackendTrafficPolicy simultaneously.
Requests are evaluated first by the local limit, then by the global limit.
Which issue(s) this PR fixes:
Fixes #7271
Release Notes: Yes