Skip to content
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

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

Conversation

bmv126
Copy link

@bmv126 bmv126 commented Feb 17, 2024

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:

nginx.ingress.kubernetes.io/limit-no-burst : Bool (Default: false) 
nginx.ingress.kubernetes.io/limit-delay: Int (Default: -1)
nginx.ingress.kubernetes.io/limit-shared-size: Int (Default: 5) 

Copy link

linux-foundation-easycla bot commented Feb 17, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bmv126
Once this PR has been reviewed and has the lgtm label, please assign cpanato for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 17, 2024
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 17, 2024
Copy link

netlify bot commented Feb 17, 2024

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
🔨 Latest commit 4aecc33
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/65d196558cb0760007b8154d

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 17, 2024
@bmv126 bmv126 changed the title Add support to make delay, size, burst configurable in limit_req directiveRate limit set delay noburst Add support to make delay, size, burst configurable in limit_req directive Feb 17, 2024
* Update main.go

* Update main_test.go

* Update template.go

* Update template_test.go
@strongjz
Copy link
Member

please add e2e test for these new annotations.

@strongjz
Copy link
Member

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.

@strongjz
Copy link
Member

Bump in asking for e2e tests.

/assign @strongjz
/triage accepted
/kind feature
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 14, 2024
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Mar 14, 2024
@strongjz
Copy link
Member

/priority backlog

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-priority labels Mar 14, 2024
@@ -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)
Copy link
Contributor

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)
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants