Skip to content

Commit cfddc11

Browse files
authored
Merge pull request #208 from Sarga/master
Add worker-shutdown-timeout configmap key
2 parents 8c943dd + 50ee9d2 commit cfddc11

File tree

9 files changed

+18
-6
lines changed

9 files changed

+18
-6
lines changed

examples/customization/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The table below summarizes some of the options. More options (extensions) are av
4040
| `nginx.org/listen-ports-ssl` | N/A | Configures HTTPS ports that NGINX will listen on. | `[443]` |
4141
| N/A | `worker-processes` | Sets the value of the [worker_processes](http://nginx.org/en/docs/ngx_core_module.html#worker_processes) directive. | `auto` |
4242
| N/A | `worker-cpu-affinity` | Sets the value of the [worker_cpu_affinity](http://nginx.org/en/docs/ngx_core_module.html#worker_cpu_affinity) directive. | N/A |
43+
| N/A | `worker-shutdown-timeout` | Sets the value of the [worker_shutdown_timeout](http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout) directive. | N/A |
4344
| `nginx.org/keepalive` | `keepalive` | Sets the value of the [keepalive](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive) directive. Note that `proxy_set_header Connection "";` is added to the generated configuration when the value > 0. | `0` |
4445

4546
## Using ConfigMaps

examples/customization/nginx-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ data:
4646
charset koi8-r;
4747
worker-processes: "1" # default is "auto". Sets the value of the worker_processes directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_processes
4848
worker-cpu-affinity: "auto" # No default. Sets the value of the worker_cpu_affinity directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_cpu_affinity
49+
worker-shutdown-timeout: "5m" # No default. Sets the value of the worker_shutdown_timeout directive. See http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout
4950
keepalive: "32" # default is 0. When > 0, sets the value of the keepalive directive and adds 'proxy_set_header Connection "";' to a location block. See http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

nginx-controller/controller/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,9 @@ func (lbc *LoadBalancerController) syncCfgm(task Task) {
582582
if workerCPUAffinity, exists := cfgm.Data["worker-cpu-affinity"]; exists {
583583
cfg.MainWorkerCPUAffinity = workerCPUAffinity
584584
}
585+
if workerShutdownTimeout, exists := cfgm.Data["worker-shutdown-timeout"]; exists {
586+
cfg.MainWorkerShutdownTimeout = workerShutdownTimeout
587+
}
585588
if keepalive, exists, err := nginx.GetMapKeyAsInt(cfgm.Data, "keepalive", cfgm); exists {
586589
if err != nil {
587590
glog.Error(err)

nginx-controller/nginx/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Config struct {
2828
LBMethod string
2929
MainWorkerProcesses string
3030
MainWorkerCPUAffinity string
31+
MainWorkerShutdownTimeout string
3132
Keepalive int64
3233

3334
// http://nginx.org/en/docs/http/ngx_http_realip_module.html

nginx-controller/nginx/configurator.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,11 +688,12 @@ func (cnf *Configurator) UpdateConfig(config *Config, ingExes []*IngressEx) erro
688688
SSLCiphers: config.MainServerSSLCiphers,
689689
SSLDHParam: config.MainServerSSLDHParam,
690690
SSLPreferServerCiphers: config.MainServerSSLPreferServerCiphers,
691-
HTTP2: config.HTTP2,
692-
ServerTokens: config.ServerTokens,
693-
ProxyProtocol: config.ProxyProtocol,
694-
WorkerProcesses: config.MainWorkerProcesses,
695-
WorkerCPUAffinity: config.MainWorkerCPUAffinity,
691+
HTTP2: config.HTTP2,
692+
ServerTokens: config.ServerTokens,
693+
ProxyProtocol: config.ProxyProtocol,
694+
WorkerProcesses: config.MainWorkerProcesses,
695+
WorkerCPUAffinity: config.MainWorkerCPUAffinity,
696+
WorkerShutdownTimeout: config.MainWorkerShutdownTimeout,
696697
}
697698

698699
cnf.nginx.UpdateMainConfigFile(mainCfg)

nginx-controller/nginx/nginx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ type NginxMainConfig struct {
117117
ProxyProtocol bool
118118
WorkerProcesses string
119119
WorkerCPUAffinity string
120+
WorkerShutdownTimeout string
120121
}
121122

122123
// NewUpstreamWithDefaultServer creates an upstream with the default server.

nginx-controller/nginx/templates/nginx-plus.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ user nginx;
33
worker_processes {{.WorkerProcesses}};
44
{{- if .WorkerCPUAffinity}}
55
worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}
6+
{{- if .WorkerShutdownTimeout}}
7+
worker_shutdown_timeout {{.WorkerShutdownTimeout}};{{end}}
68

79
daemon off;
810

nginx-controller/nginx/templates/nginx.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ user nginx;
33
worker_processes {{.WorkerProcesses}};
44
{{- if .WorkerCPUAffinity}}
55
worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}
6-
6+
{{- if .WorkerShutdownTimeout}}
7+
worker_shutdown_timeout {{.WorkerShutdownTimeout}};{{end}}
78
daemon off;
89

910
error_log /var/log/nginx/error.log warn;

nginx-controller/nginx/templates/templates_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ var mainCfg = nginx.NginxMainConfig{
5656
ServerTokens: "off",
5757
WorkerProcesses: "auto",
5858
WorkerCPUAffinity: "auto",
59+
WorkerShutdownTimeout: "1m",
5960
}
6061

6162
func TestIngressForNGINXPlus(t *testing.T) {

0 commit comments

Comments
 (0)