Skip to content

moved shared under rules #5944

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

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

Conversation

ryanhristovski
Copy link
Contributor

@ryanhristovski ryanhristovski commented May 7, 2025

  • updates the global shared rate limit logic to be under each ratelimit rule rather than the entire ratelimit spec
  • removed patching keys and name value in ratelimit rule api
  • remove Name field from TrafficFeatures IR, add patch keys to traffic features IR rules
  • adds auto-generated Name field to RateLimitRule (this is the key for merging logic)
  • updates ratelimit.go logic to work for shared/non-shared fields within each rule

Before:

    rateLimit:
      shared: true
      global:
        rules:
        - clientSelectors:
          - headers:
            - name: x-user-id
              type: Exact
              value: one
          limit:
            requests: 5
            unit: Hour

After:

    rateLimit:
      global:
        rules:
        - clientSelectors:
          - headers:
            - name: x-user-id
              type: Exact
              value: one
          shared: true
          limit:
            requests: 5
            unit: Hour
        - clientSelectors:
          - headers:
            - name: x-user-id
              type: Exact
              value: two
          shared: false
          limit:
            requests: 5
            unit: Hour

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]>
Copy link

codecov bot commented May 7, 2025

Codecov Report

Attention: Patch coverage is 64.09266% with 93 lines in your changes missing coverage. Please review.

Project coverage is 65.74%. Comparing base (00ebb2f) to head (a594c36).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/ratelimit.go 78.10% 29 Missing and 15 partials ⚠️
internal/utils/merge.go 0.00% 42 Missing ⚠️
internal/gatewayapi/backendtrafficpolicy.go 50.00% 4 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5944      +/-   ##
==========================================
- Coverage   65.80%   65.74%   -0.06%     
==========================================
  Files         217      217              
  Lines       36056    36195     +139     
==========================================
+ Hits        23726    23796      +70     
- Misses      10854    10909      +55     
- Partials     1476     1490      +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.

@ryanhristovski ryanhristovski marked this pull request as ready for review May 9, 2025 17:51
@ryanhristovski ryanhristovski requested a review from a team as a code owner May 9, 2025 17:51
Signed-off-by: Ryan Hristovski <[email protected]>
timeout:
http:
Copy link
Contributor

@arkodg arkodg May 9, 2025

Choose a reason for hiding this comment

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

why did this get wiped out ?

Copy link
Contributor

Choose a reason for hiding this comment

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

may be related to #5967

@@ -23,25 +23,7 @@ spec:
limit:
requests: 21
unit: Hour
name: two
Copy link
Contributor

Choose a reason for hiding this comment

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

why did this get deleted ?

Signed-off-by: Ryan Hristovski <[email protected]>
Signed-off-by: Ryan Hristovski <[email protected]>
@arkodg
Copy link
Contributor

arkodg commented May 10, 2025

looks like all the e2e are failing

} else {
hasNonShared = true
}
if hasShared && hasNonShared {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed, imo will never be true

for _, rule := range route.Traffic.RateLimit.Global.Rules {
if isRuleShared(rule) {
hasShared = true
if sharedRuleName == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

is sharedRuleName == "" required , or should we rely on stripRuleIndexSuffix to gracefully handle it even when the input is unlikely

Value: value,
Descriptors: serviceDescriptors,
for i, rule := range route.Traffic.RateLimit.Global.Rules {
if i >= len(serviceDescriptors) || (includeShared != isRuleShared(rule)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why the logic around descriptor creation has increased, shouldnt it be the same and leverage the rule name for descriptor key and value ?

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