-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add support to make delay, size, burst configurable in limit_req directive #10990
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bmv126 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @bmv126. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
✅ Deploy Preview for kubernetes-ingress-nginx canceled.
|
please add e2e test for these new annotations. |
And when it's ready to go, please squash into one commit; I believe the bot can do it for us, but it's always easier if it's done as well. |
Bump in asking for e2e tests. /assign @strongjz |
/priority backlog |
@@ -237,6 +262,22 @@ func (a ratelimit) Parse(ing *networking.Ingress) (interface{}, error) { | |||
burstMultiplier = defBurst | |||
} | |||
|
|||
//nolint:errcheck // No need to check err here | |||
noburst, _ := parser.GetBoolAnnotation(limitRateNoBurstAnnotation, ing, a.annotationConfig.Annotations) |
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.
why no error check here? I would liek to not skip any error check
@@ -877,14 +877,34 @@ func buildRateLimit(input interface{}) []string { | |||
} | |||
|
|||
if loc.RateLimit.RPS.Limit > 0 { | |||
limit := fmt.Sprintf("limit_req zone=%v burst=%v nodelay;", | |||
loc.RateLimit.RPS.Name, loc.RateLimit.RPS.Burst) | |||
limit := fmt.Sprintf("limit_req zone=%v", loc.RateLimit.RPS.Name) |
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.
please use %d instead of %v on any call. or %s. In this case, as this is a string, let's stick with %s and on the other cases with %d
In current code below is the behaviour for limit_req and limit_req_zone directives :
a) burst is always set even if user does not need it.
b) delay is always set to nodelay.
c) zone size is not configurable and set to 5m.
In nginx delay and burst are optional.
http://nginx.org/en/docs/http/ngx_http_limit_req_module.html#limit_req
This commit adds support to make delay, zone size configurable and also make burst optional.
Below annotations are added to support it: