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

Added max-conns annotation #614

Merged
merged 4 commits into from
Jul 8, 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
9 changes: 9 additions & 0 deletions internal/configs/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var minionInheritanceList = map[string]bool{
"nginx.org/lb-method": true,
"nginx.org/keepalive": true,
"nginx.org/max-fails": true,
"nginx.org/max-conns": true,
"nginx.org/fail-timeout": true,
}

Expand Down Expand Up @@ -285,6 +286,14 @@ func parseAnnotations(ingEx *IngressEx, baseCfgParams *ConfigParams, isPlus bool
}
}

if maxConns, exists, err := GetMapKeyAsInt(ingEx.Ingress.Annotations, "nginx.org/max-fails", ingEx.Ingress); exists {
Dean-Coakley marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
glog.Error(err)
} else {
cfgParams.MaxConns = maxConns
}
}

if failTimeout, exists := ingEx.Ingress.Annotations["nginx.org/fail-timeout"]; exists {
cfgParams.FailTimeout = failTimeout
}
Expand Down
2 changes: 2 additions & 0 deletions internal/configs/config_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ConfigParams struct {
MainWorkerRlimitNofile string
Keepalive int64
MaxFails int
MaxConns int
FailTimeout string
HealthCheckEnabled bool
HealthCheckMandatory bool
Expand Down Expand Up @@ -101,6 +102,7 @@ func NewDefaultConfigParams() *ConfigParams {
Ports: []int{80},
SSLPorts: []int{443},
MaxFails: 1,
MaxConns: 0,
FailTimeout: "10s",
LBMethod: "random two least_conn",
MainErrorLogLevel: "notice",
Expand Down
2 changes: 2 additions & 0 deletions internal/configs/version1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type UpstreamServer struct {
Address string
Port string
MaxFails int
MaxConns int
FailTimeout string
SlowStart string
Resolve bool
Expand Down Expand Up @@ -168,6 +169,7 @@ func NewUpstreamWithDefaultServer(name string) Upstream {
Address: "127.0.0.1",
Port: "8181",
MaxFails: 1,
MaxConns: 0,
FailTimeout: "10s",
},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/configs/version1/nginx.ingress.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
upstream {{$upstream.Name}} {
{{if $upstream.LBMethod }}{{$upstream.LBMethod}};{{end}}
{{range $server := $upstream.UpstreamServers}}
server {{$server.Address}}:{{$server.Port}} max_fails={{$server.MaxFails}} fail_timeout={{$server.FailTimeout}};{{end}}
server {{$server.Address}}:{{$server.Port}} max_fails={{$server.MaxFails}} fail_timeout={{$server.FailTimeout}} max_conns={{$server.MaxConns}};{{end}}
{{if $.Keepalive}}keepalive {{$.Keepalive}};{{end}}
}{{end}}

Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var testUps = Upstream{
Address: "127.0.0.1",
Port: "8181",
MaxFails: 0,
MaxConns: 0,
FailTimeout: "1s",
SlowStart: "5s",
},
Expand Down