-
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
Wrong calculation for ServerNameHashMaxSize? #564
Comments
…to be wrong See also kubernetes#564
var serverNames int
for _, srv := range ingressCfg.Servers {
serverNames += len([]byte(srv.Hostname))
if longestName < len(srv.Hostname) {
longestName = len(srv.Hostname)
}
} At the end we have serverNameHashMaxSize := nextPowerOf2(serverNames)
if serverNameHashMaxSize > cfg.ServerNameHashMaxSize {
glog.V(3).Infof("adjusting ServerNameHashMaxSize variable from %v to %v",
cfg.ServerNameHashMaxSize, serverNameHashMaxSize)
cfg.ServerNameHashMaxSize = serverNameHashMaxSize
} So here we end up with So this calculation seems to "overestimate" the needed space in the table. |
Right. What alternative you propose? If we leave this as a parameter (until 0.8.3) every time you add a new ingress you could end with a non working nginx configuration. Honestly I prefer overestimate the size of the table. |
Being able to configure things is definitely helpful ... in fact the reason I started to look at this code in the first place is that I hit the other limit and didn't know there is a way to configure it :) Rough idea would be this though: diff --git a/controllers/nginx/pkg/cmd/controller/nginx.go b/controllers/nginx/pkg/cmd/controller/nginx.go
index a57df8d..be30b67 100644
--- a/controllers/nginx/pkg/cmd/controller/nginx.go
+++ b/controllers/nginx/pkg/cmd/controller/nginx.go
@@ -327,9 +327,7 @@ func (n *NGINXController) SetListers(lister ingress.StoreLister) {
// if an error is returned means requeue the update
func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) ([]byte, error) {
var longestName int
- var serverNames int
for _, srv := range ingressCfg.Servers {
- serverNames += len([]byte(srv.Hostname))
if longestName < len(srv.Hostname) {
longestName = len(srv.Hostname)
}
@@ -358,7 +356,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) ([]byte, er
cfg.ServerNameHashBucketSize, nameHashBucketSize)
cfg.ServerNameHashBucketSize = nameHashBucketSize
}
- serverNameHashMaxSize := nextPowerOf2(serverNames)
+ serverNameHashMaxSize := nextPowerOf2(len(ingressCfg.Servers))
if serverNameHashMaxSize > cfg.ServerNameHashMaxSize {
glog.V(3).Infof("adjusting ServerNameHashMaxSize variable from %v to %v",
cfg.ServerNameHashMaxSize, serverNameHashMaxSize) |
@ankon I think we can change the default
|
@ankon friendly ping |
With 0.9-beta.4 and 8 ingresses each doing 4 urls (of various length 26-47 chars) I start getting this error.
|
https://github.com/kubernetes/ingress/blob/master/controllers/nginx/pkg/cmd/controller/nginx.go#L328 tries to auto-size the hash for the server names, and it uses the total number of bytes for all server names to determine ServerNameHashMaxSize.
But, according to http://nginx.org/en/docs/http/server_names.html#optimization that seems wrong, and instead the number of server names should be considered:
Am I missing something here?
The text was updated successfully, but these errors were encountered: