-
Notifications
You must be signed in to change notification settings - Fork 822
feat: add optional name field to RateLimitRule for improved observability #9466
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?
Changes from all commits
53b621d
c7ba8d1
7f71d3d
5d5c7d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1422,8 +1422,8 @@ func (t *Translator) buildLocalRateLimit(policy *egv1a1.BackendTrafficPolicy) (* | |
| if err != nil { | ||
| return nil, err | ||
| } | ||
| // Set the Name field as <policy-ns>/<policy-name>/rule/<rule-index> | ||
| irRule.Name = irRuleName(policy.Namespace, policy.Name, i) | ||
| // Set the Name field as <policy-ns>/<policy-name>/rule/<rule-name-or-index> | ||
| irRule.Name = irRuleName(policy.Namespace, policy.Name, i, rule.Name) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a local rule has Useful? React with 👍 / 👎. |
||
| irRules = append(irRules, irRule) | ||
| } | ||
|
|
||
|
|
@@ -1460,8 +1460,8 @@ func (t *Translator) buildGlobalRateLimit(policy *egv1a1.BackendTrafficPolicy) ( | |
| if err != nil { | ||
| return nil, err | ||
| } | ||
| // Set the Name field as <policy-ns>/<policy-name>/rule/<rule-index> | ||
| irRules[i].Name = irRuleName(policy.Namespace, policy.Name, i) | ||
| // Set the Name field as <policy-ns>/<policy-name>/rule/<rule-name-or-index> | ||
| irRules[i].Name = irRuleName(policy.Namespace, policy.Name, i, rule.Name) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For the default global case ( Useful? React with 👍 / 👎. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a global rule without Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| return rateLimit, nil | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| gateways: | ||
| - apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: Gateway | ||
| metadata: | ||
| namespace: envoy-gateway | ||
| name: gateway-1 | ||
| spec: | ||
| gatewayClassName: envoy-gateway-class | ||
| listeners: | ||
| - name: http | ||
| protocol: HTTP | ||
| port: 80 | ||
| allowedRoutes: | ||
| namespaces: | ||
| from: All | ||
| httpRoutes: | ||
| - apiVersion: gateway.networking.k8s.io/v1 | ||
| kind: HTTPRoute | ||
| metadata: | ||
| namespace: default | ||
| name: httproute-1 | ||
| spec: | ||
| hostnames: | ||
| - gateway.envoyproxy.io | ||
| parentRefs: | ||
| - namespace: envoy-gateway | ||
| name: gateway-1 | ||
| sectionName: http | ||
| rules: | ||
| - matches: | ||
| - path: | ||
| value: "/" | ||
| backendRefs: | ||
| - name: service-1 | ||
| port: 8080 | ||
| backendTrafficPolicies: | ||
| - apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
| kind: BackendTrafficPolicy | ||
| metadata: | ||
| namespace: default | ||
| name: policy-for-route | ||
| spec: | ||
| targetRef: | ||
| group: gateway.networking.k8s.io | ||
| kind: HTTPRoute | ||
| name: httproute-1 | ||
| rateLimit: | ||
| type: Global | ||
| global: | ||
| rules: | ||
| # Named shared rule -> key uses the name: default/policy-for-route/rule/by-ip | ||
| - name: by-ip | ||
| clientSelectors: | ||
| - sourceCIDR: | ||
| type: "Distinct" | ||
| value: "0.0.0.0/0" | ||
| limit: | ||
| requests: 20 | ||
| unit: Hour | ||
| shared: true | ||
| # Named non-shared rule -> key uses the name: default/policy-for-route/rule/by-org | ||
| - name: by-org | ||
| clientSelectors: | ||
| - headers: | ||
| - name: x-org-id | ||
| type: Distinct | ||
| limit: | ||
| requests: 30 | ||
| unit: Hour | ||
| # Unnamed rule -> key falls back to the index: default/policy-for-route/rule/2 | ||
| - clientSelectors: | ||
| - headers: | ||
| - name: x-team | ||
| value: blue | ||
| limit: | ||
| requests: 40 | ||
| unit: Hour |
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 accepts
spec.rateLimit.local.rules[].nameand stores it in the IR, but I checkedinternal/xds/translator/local_ratelimit.goand local descriptor/action construction never readsrule.Name; it uses the loop indexrIdxfor allrule-<n>-*keys. Users can now configure a valid local rule name that has no observable effect and still gets index-based descriptor churn after reordering. Please either use the name in local descriptor generation or disallow/document the field for local rate limits.Useful? React with 👍 / 👎.