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

feat [ratelimiting] support global ratelimit buckets #5361

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

ryanhristovski
Copy link
Contributor

@ryanhristovski ryanhristovski commented Feb 26, 2025

Core logic in internal/xds/translator/ratelimit.go

Description

Descriptor/Domain Changes

  • If the ratelimit is shared the following values are set
Descriptor Key = BackendTrafficPolicy.Name
Descriptor Value = BackendTrafficPolicy.Namespace
Domain = BackendTrafficPolicy.Name + "-" BackendTrafficPolicy.Namespace

This will allow the ratelimit to be shared across all xRoutes/Gateways that share this BackendTrafficPolicy (BTP).

  • If the ratelimit is not shared, it will use the listener name as the domain and maintain previous descriptor key/value of the route name.

HTTPFilter Changes

  • Since we are now potentially using multiple domains, we needed to create multiple Ratelimit HTTPFilters to associate with them, buildRateLimitFilter now builds a list of filters.

API Changes

  • GlobalRateLimit, now includes Shared value responsible for enabling this logic
  • TrafficFeatures, responsible for holding all information associated to BTP, now includes BTP metadata including BTP.name and BTP.namespace (this is used for setting domains & descriptors)

Runner changes

  • Runner now iterates through a list of Ratelimit configuration now that there can be multiple

Testing

  • Ratelimit-config translator has been updated to build multiple configurations separated by --- in order to account for the multiple domains that are now being used.
  • All tests have been updated to account for new traffic.BackendTrafficPolicy fields

TODO:

Signed-off-by: Ryan Hristovski <[email protected]>

remove xds shared, not needed

Signed-off-by: Ryan Hristovski <[email protected]>

fmt

Signed-off-by: Ryan Hristovski <[email protected]>

update docs

Signed-off-by: Ryan Hristovski <[email protected]>

docs

Signed-off-by: Ryan Hristovski <[email protected]>

Update api/v1alpha1/ratelimit_types.go

Co-authored-by: Arko Dasgupta <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>

Update api/v1alpha1/ratelimit_types.go

Co-authored-by: Arko Dasgupta <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>

remove internal from api pr, will be added later

Signed-off-by: Ryan Hristovski <[email protected]>

move shared field from ratelimit to globalratelimit

Signed-off-by: Ryan Hristovski <[email protected]>

add +notImplementedHide marker

Signed-off-by: Ryan Hristovski <[email protected]>

remove internal/ changes

Signed-off-by: Ryan Hristovski <[email protected]>

remove /internal docs

Signed-off-by: Ryan Hristovski <[email protected]>

fmt

Signed-off-by: Ryan Hristovski <[email protected]>

fmt

Signed-off-by: Ryan Hristovski <[email protected]>

fix broken test

Signed-off-by: Ryan Hristovski <[email protected]>

chore: bump deps (envoyproxy#5263)

* build(deps): bump github.com/envoyproxy/go-control-plane/contrib

Bumps [github.com/envoyproxy/go-control-plane/contrib](https://github.com/envoyproxy/go-control-plane) from 1.32.3 to 1.32.4.
- [Release notes](https://github.com/envoyproxy/go-control-plane/releases)
- [Changelog](https://github.com/envoyproxy/go-control-plane/blob/main/CHANGELOG.md)
- [Commits](envoyproxy/go-control-plane@envoy/v1.32.3...envoy/v1.32.4)

---
updated-dependencies:
- dependency-name: github.com/envoyproxy/go-control-plane/contrib
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* build(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6

Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6.
- [Release notes](https://github.com/spf13/pflag/releases)
- [Commits](spf13/pflag@v1.0.5...v1.0.6)

---
updated-dependencies:
- dependency-name: github.com/spf13/pflag
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix gen

Signed-off-by: zirain <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: zirain <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Ryan Hristovski <[email protected]>

Update generated files for gen-check

Signed-off-by: Ryan Hristovski <[email protected]>

working ratelimit.go, lets break it now :)

Signed-off-by: Ryan Hristovski <[email protected]>

working multi listener, multi http filter, etc

Signed-off-by: Ryan Hristovski <[email protected]>

commitMsz

readd comments

Signed-off-by: Ryan Hristovski <[email protected]>

remove todo

Signed-off-by: Ryan Hristovski <[email protected]>
@ryanhristovski ryanhristovski force-pushed the feat-global-gateway-ratelimitting-logic branch from 917eb2b to 8e2ccbe Compare February 26, 2025 19:41
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
ryanhristovski and others added 4 commits March 8, 2025 12:45
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 70.62937% with 84 lines in your changes missing coverage. Please review.

Project coverage is 65.26%. Comparing base (12336d8) to head (cfe8613).

Files with missing lines Patch % Lines
internal/xds/translator/ratelimit.go 64.78% 65 Missing and 16 partials ⚠️
internal/globalratelimit/runner/runner.go 72.72% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5361      +/-   ##
==========================================
- Coverage   65.34%   65.26%   -0.08%     
==========================================
  Files         213      213              
  Lines       33915    34062     +147     
==========================================
+ Hits        22162    22232      +70     
- Misses      10426    10489      +63     
- Partials     1327     1341      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Ryan Hristovski <[email protected]>
@ryanhristovski ryanhristovski marked this pull request as ready for review March 8, 2025 19:50
@ryanhristovski ryanhristovski requested a review from a team as a code owner March 8, 2025 19:50
@ryanhristovski ryanhristovski changed the title WIP [ratelimiting] support global ratelimit buckets feat [ratelimiting] support global ratelimit buckets Mar 8, 2025
@ryanhristovski
Copy link
Contributor Author

/retest

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