GoogleCloudPlatform / k8s-cloud-provider

Support code for implementing a Kubernetes cloud provider for Google Cloud Platform
Apache License 2.0
37 stars 46 forks source link

Add new types of rate limiters #200

Closed AwesomePatrol closed 6 months ago

AwesomePatrol commented 6 months ago
  1. TickerRateLimiter is a simple implementation based on time.Ticker suggested in https://go.dev/wiki/RateLimiting. It works by spacing requests in predefined intervals. It doesn't allows bursts although it is fairly easy to add. A good candidate for replacement would be https://github.com/uber-go/ratelimit which supports "slack"
  2. CompositeRateLimiter doesn't implement any rate limiting algorithm, but allows to combine all rate limiters (implementing the RateLimiter interface). A user can specify what rate limiter should be used for a specific combination of project, service and operation. An example usage is available in e2e/testmain_test.go where there are two TickerRateLimiters used for Compute and NetworkServices API; and two MinimumRateLimiters for Operations and as a fallback for all other requests

Bug: b/337197802

AwesomePatrol commented 6 months ago

/cc @kl52752

bowei commented 6 months ago

/hold

/approve (generally ok, please fix the comments I left, otherwise @kl52752, please complete the review and remove the hold)

bowei commented 6 months ago

/approve

AwesomePatrol commented 6 months ago

/retest

kl52752 commented 6 months ago

/lgtm

/approve

google-oss-prow[bot] commented 6 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AwesomePatrol, bowei, kl52752

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/GoogleCloudPlatform/k8s-cloud-provider/blob/master/OWNERS)~~ [bowei] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
kl52752 commented 6 months ago

/remove-hold