diff --git a/internal/ingress/annotations/ratelimit/main.go b/internal/ingress/annotations/ratelimit/main.go index 42cf17a0b..a502148ee 100644 --- a/internal/ingress/annotations/ratelimit/main.go +++ b/internal/ingress/annotations/ratelimit/main.go @@ -262,6 +262,7 @@ 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) if noburst { burstMultiplier = 0 diff --git a/internal/ingress/annotations/ratelimit/main_test.go b/internal/ingress/annotations/ratelimit/main_test.go index 9bb6df634..9eade807a 100644 --- a/internal/ingress/annotations/ratelimit/main_test.go +++ b/internal/ingress/annotations/ratelimit/main_test.go @@ -210,7 +210,6 @@ func TestRateLimiting(t *testing.T) { data[parser.GetAnnotationWithPrefix(limitRateConnectionsAnnotation)] = "5" data[parser.GetAnnotationWithPrefix(limitRateRPSAnnotation)] = "100" data[parser.GetAnnotationWithPrefix(limitRateRPMAnnotation)] = "10" - data[parser.GetAnnotationWithPrefix(limitRateAfterAnnotation)] = "100" data[parser.GetAnnotationWithPrefix(limitRateAnnotation)] = "10" data[parser.GetAnnotationWithPrefix(limitRateBurstMultiplierAnnotation)] = "3" data[parser.GetAnnotationWithPrefix(limitRateNoBurstAnnotation)] = "true" @@ -259,9 +258,6 @@ func TestRateLimiting(t *testing.T) { if rateLimit.RPM.SharedSize != 1 { t.Errorf("expected %d in sharedSize limit by rps but %v was returned", 1, rateLimit.RPM) } - if rateLimit.LimitRateAfter != 100 { - t.Errorf("expected 100 in limit by limitrateafter but %v was returned", rateLimit.LimitRateAfter) - } if rateLimit.LimitRate != 10 { t.Errorf("expected 10 in limit by limitrate but %v was returned", rateLimit.LimitRate) } diff --git a/internal/ingress/controller/template/template.go b/internal/ingress/controller/template/template.go index 6098b1833..742d1f57f 100644 --- a/internal/ingress/controller/template/template.go +++ b/internal/ingress/controller/template/template.go @@ -879,9 +879,7 @@ func buildRateLimit(input interface{}) []string { if loc.RateLimit.RPS.Limit > 0 { limit := fmt.Sprintf("limit_req zone=%v", loc.RateLimit.RPS.Name) - if loc.RateLimit.RPS.Burst == 0 { - limit = fmt.Sprintf("%v", limit) - } else { + if loc.RateLimit.RPS.Burst > 0 { limit = fmt.Sprintf("%v burst=%v", limit, loc.RateLimit.RPS.Burst) } @@ -897,9 +895,7 @@ func buildRateLimit(input interface{}) []string { if loc.RateLimit.RPM.Limit > 0 { limit := fmt.Sprintf("limit_req zone=%v", loc.RateLimit.RPM.Name) - if loc.RateLimit.RPM.Burst == 0 { - limit = fmt.Sprintf("%v", limit) - } else { + if loc.RateLimit.RPM.Burst > 0 { limit = fmt.Sprintf("%v burst=%v", limit, loc.RateLimit.RPM.Burst) } diff --git a/internal/ingress/controller/template/template_test.go b/internal/ingress/controller/template/template_test.go index 846a4c3e3..d0619e807 100644 --- a/internal/ingress/controller/template/template_test.go +++ b/internal/ingress/controller/template/template_test.go @@ -1012,19 +1012,19 @@ func TestBuildRateLimit(t *testing.T) { loc = &ingress.Location{} - loc.RateLimit.RPS.Name = "rps" + loc.RateLimit.RPS.Name = "rps_nodelay" loc.RateLimit.RPS.Limit = 1 loc.RateLimit.RPS.Burst = 0 loc.RateLimit.RPS.Delay = -1 - loc.RateLimit.RPM.Name = "rpm" + loc.RateLimit.RPM.Name = "rpm_nodelay" loc.RateLimit.RPM.Limit = 2 loc.RateLimit.RPM.Burst = 0 loc.RateLimit.RPM.Delay = -1 validLimits = []string{ - "limit_req zone=rps nodelay;", - "limit_req zone=rpm nodelay;", + "limit_req zone=rps_nodelay nodelay;", + "limit_req zone=rpm_nodelay nodelay;", } limits = buildRateLimit(loc)