Skip to content

Commit

Permalink
Fix limit by label key (#3033)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Updated label key retrieval logic in quota scheduler to enhance
performance and maintain compatibility with new rate limiter interface.
- **Deprecations**
- Added deprecation warnings for fallback usage of the old `GetLabelKey`
method in rate limiting scenarios.
- **Documentation**
- Updated method signatures to reflect changes in label key retrieval
process.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
tanveergill authored Dec 6, 2023
1 parent 57df573 commit 6de3000
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,11 @@ func (qs *quotaScheduler) GetSelectors() []*policylangv1.Selector {
}

func (qs *quotaScheduler) getLabelKey(labels labels.Labels) (string, bool) {
labelKey := qs.proto.RateLimiter.GetLabelKey()
labelKey := qs.proto.RateLimiter.GetLimitByLabelKey()
if labelKey == "" {
// Deprecated: Remove in v3.0.0
labelKey = qs.proto.RateLimiter.GetLabelKey()
}
var label string
if labelKey == "" {
label = "default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@ func (rl *rateLimiter) TakeIfAvailable(
return label, true, 0, 0, 0
}

labelKey := rl.lbProto.Parameters.GetLabelKey()
labelKey := rl.lbProto.Parameters.GetLimitByLabelKey()
if labelKey == "" {
// Deprecated: Remove in v3.0.0
labelKey = rl.lbProto.Parameters.GetLabelKey()
}
if labelKey == "" {
label = "default"
} else {
Expand Down

0 comments on commit 6de3000

Please sign in to comment.