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 max_conns support for nginx plus #631

Merged
merged 2 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/configs/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ func (cnf *Configurator) updatePlusEndpoints(ingEx *IngressEx) error {

cfg := nginx.ServerConfig{
MaxFails: ingCfg.MaxFails,
MaxConns: ingCfg.MaxConns,
FailTimeout: ingCfg.FailTimeout,
SlowStart: ingCfg.SlowStart,
}
Expand Down
4 changes: 4 additions & 0 deletions internal/configs/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig {
Address: "10.0.0.1",
Port: "80",
MaxFails: 1,
MaxConns: 0,
FailTimeout: "10s",
},
},
Expand All @@ -142,6 +143,7 @@ func createExpectedConfigForCafeIngressEx() version1.IngressNginxConfig {
Address: "10.0.0.2",
Port: "80",
MaxFails: 1,
MaxConns: 0,
FailTimeout: "10s",
},
},
Expand Down Expand Up @@ -481,6 +483,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig {
Address: "10.0.0.1",
Port: "80",
MaxFails: 1,
MaxConns: 0,
FailTimeout: "10s",
},
},
Expand All @@ -493,6 +496,7 @@ func createExpectedConfigForMergeableCafeIngress() version1.IngressNginxConfig {
Address: "10.0.0.2",
Port: "80",
MaxFails: 1,
MaxConns: 0,
FailTimeout: "10s",
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/configs/version1/nginx-plus.ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ upstream {{$upstream.Name}} {
zone {{$upstream.Name}} 256k;
{{if $upstream.LBMethod }}{{$upstream.LBMethod}};{{end}}
{{range $server := $upstream.UpstreamServers}}
server {{$server.Address}}:{{$server.Port}} max_fails={{$server.MaxFails}} fail_timeout={{$server.FailTimeout}}
server {{$server.Address}}:{{$server.Port}} max_fails={{$server.MaxFails}} fail_timeout={{$server.FailTimeout}} max_conns={{$server.MaxConns}}
{{- if $server.SlowStart}} slow_start={{$server.SlowStart}}{{end}}{{if $server.Resolve}} resolve{{end}};{{end}}
{{if $upstream.StickyCookie}}
sticky cookie {{$upstream.StickyCookie}};
Expand Down
2 changes: 2 additions & 0 deletions internal/nginx/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const jsonFileForOpenTracingTracer = "/etc/tracer-config.json"
// ServerConfig holds the config data for an upstream server in NGINX Plus.
type ServerConfig struct {
MaxFails int
MaxConns int
FailTimeout string
SlowStart string
}
Expand Down Expand Up @@ -265,6 +266,7 @@ func (lm *LocalManager) UpdateServersInPlus(upstream string, servers []string, c
upsServers = append(upsServers, client.UpstreamServer{
Server: s,
MaxFails: config.MaxFails,
MaxConns: config.MaxConns,
FailTimeout: config.FailTimeout,
SlowStart: config.SlowStart,
})
Expand Down