Skip to content

Commit

Permalink
Calculation algorithm for server_names_hash_bucket_size should consid…
Browse files Browse the repository at this point in the history
…er annotations (#4993)
  • Loading branch information
aledbf authored Jan 31, 2020
1 parent beef9fa commit 5d6f09f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,14 +499,25 @@ func (n NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressC
var serverNameBytes int

for _, srv := range ingressCfg.Servers {
if longestName < len(srv.Hostname) {
longestName = len(srv.Hostname)
hostnameLength := len(srv.Hostname)
if srv.RedirectFromToWWW {
hostnameLength += 4
}
serverNameBytes += len(srv.Hostname)
if longestName < hostnameLength {
longestName = hostnameLength
}

for _, alias := range srv.Aliases {
if longestName < len(alias) {
longestName = len(alias)
}
}

serverNameBytes += hostnameLength
}

if cfg.ServerNameHashBucketSize == 0 {
nameHashBucketSize := nginxHashBucketSize(longestName)
nameHashBucketSize := nginxHashBucketSize(longestName)
if cfg.ServerNameHashBucketSize < nameHashBucketSize {
klog.V(3).Infof("Adjusting ServerNameHashBucketSize variable to %d", nameHashBucketSize)
cfg.ServerNameHashBucketSize = nameHashBucketSize
}
Expand Down

0 comments on commit 5d6f09f

Please sign in to comment.