Skip to content

Commit

Permalink
nginx-ingress: warn that path level rate limit is applied separately …
Browse files Browse the repository at this point in the history
…for each path (#147)
  • Loading branch information
dobegor authored Aug 27, 2021
1 parent 6a3e525 commit 9daa47a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions generators/nginx_ingress/nginx_ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ func (g *Generator) shouldSplit(opts *options.Options, spec *openapi3.T) bool {
return true
}

rateLimitWarned := false

for path, pathItem := range spec.Paths {
if pathSubOptions, ok := opts.PathSubOptions[path]; ok {
// a path is disabled
Expand All @@ -329,6 +331,14 @@ func (g *Generator) shouldSplit(opts *options.Options, spec *openapi3.T) bool {
// a path has non-zero, different from global scope rate limits options
if !reflect.DeepEqual(options.RateLimitOptions{}, pathSubOptions.RateLimits) &&
!reflect.DeepEqual(opts.RateLimits, pathSubOptions.RateLimits) {

if !rateLimitWarned {
log.New(os.Stderr, "WARN", log.Lmsgprefix).
Printf("Setting a rate limit option on the path level would cause a separate rate limit applied for each path")

rateLimitWarned = true
}

return true
}

Expand Down

0 comments on commit 9daa47a

Please sign in to comment.