diff --git a/cmd/nginx-ingress/main.go b/cmd/nginx-ingress/main.go index 1b19f187a9..193ad903af 100644 --- a/cmd/nginx-ingress/main.go +++ b/cmd/nginx-ingress/main.go @@ -142,9 +142,8 @@ var ( nginxDebug = flag.Bool("nginx-debug", false, "Enable debugging for NGINX. Uses the nginx-debug binary. Requires 'error-log-level: debug' in the ConfigMap.") - nginxReloadTimeout = flag.Int("nginx-reload-timeout", 0, - `The timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. - The default is 4000 (or 20000 if -enable-app-protect is true). If set to 0, the default value will be used`) + nginxReloadTimeout = flag.Int("nginx-reload-timeout", 60000, + `The timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. (default 60000)`) wildcardTLSSecret = flag.String("wildcard-tls-secret", "", `A Secret with a TLS certificate and key for TLS termination of every Ingress host for which TLS termination is enabled but the Secret is not specified. @@ -406,7 +405,8 @@ func main() { if useFakeNginxManager { nginxManager = nginx.NewFakeManager("/etc/nginx") } else { - nginxManager = nginx.NewLocalManager("/etc/nginx/", *nginxDebug, managerCollector, parseReloadTimeout(*appProtect, *nginxReloadTimeout)) + timeout := time.Duration(*nginxReloadTimeout) * time.Millisecond + nginxManager = nginx.NewLocalManager("/etc/nginx/", *nginxDebug, managerCollector, timeout) } nginxVersion := nginxManager.Version() isPlus := strings.Contains(nginxVersion, "plus") @@ -853,21 +853,6 @@ func handleTerminationWithAppProtect(lbc *k8s.LoadBalancerController, nginxManag os.Exit(0) } -func parseReloadTimeout(appProtectEnabled bool, timeout int) time.Duration { - const defaultTimeout = 4000 * time.Millisecond - const defaultTimeoutAppProtect = 20000 * time.Millisecond - - if timeout != 0 { - return time.Duration(timeout) * time.Millisecond - } - - if appProtectEnabled { - return defaultTimeoutAppProtect - } - - return defaultTimeout -} - func ready(lbc *k8s.LoadBalancerController) http.HandlerFunc { return func(w http.ResponseWriter, _ *http.Request) { if !lbc.IsNginxReady() { diff --git a/cmd/nginx-ingress/main_test.go b/cmd/nginx-ingress/main_test.go index 049eb66b73..2f780db2e2 100644 --- a/cmd/nginx-ingress/main_test.go +++ b/cmd/nginx-ingress/main_test.go @@ -4,7 +4,6 @@ import ( "errors" "reflect" "testing" - "time" ) func TestValidatePort(t *testing.T) { @@ -124,39 +123,3 @@ func TestValidateLocation(t *testing.T) { } } } - -func TestParseReloadTimeout(t *testing.T) { - tests := []struct { - timeout int - appProtectEnabled bool - expected time.Duration - }{ - { - timeout: 0, - appProtectEnabled: true, - expected: 20000 * time.Millisecond, - }, - { - timeout: 0, - appProtectEnabled: false, - expected: 4000 * time.Millisecond, - }, - { - timeout: 1000, - appProtectEnabled: true, - expected: 1000 * time.Millisecond, - }, - { - timeout: 1000, - appProtectEnabled: false, - expected: 1000 * time.Millisecond, - }, - } - - for _, test := range tests { - result := parseReloadTimeout(test.appProtectEnabled, test.timeout) - if result != test.expected { - t.Errorf("parseReloadTimeout(%v, %v) returned %v but expected %v", test.appProtectEnabled, test.timeout, result, test.expected) - } - } -} diff --git a/deployments/helm-chart/README.md b/deployments/helm-chart/README.md index d0f997f395..a650445d29 100644 --- a/deployments/helm-chart/README.md +++ b/deployments/helm-chart/README.md @@ -147,7 +147,7 @@ Parameter | Description | Default `controller.name` | The name of the Ingress controller daemonset or deployment. | Autogenerated `controller.kind` | The kind of the Ingress controller installation - deployment or daemonset. | deployment `controller.nginxplus` | Deploys the Ingress controller for NGINX Plus. | false -`controller.nginxReloadTimeout` | The timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. The default is 4000 (or 20000 if `controller.appprotect.enable` is true). If set to 0, the default value will be used. | 0 +`controller.nginxReloadTimeout` | The timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. | 60000 `controller.hostNetwork` | Enables the Ingress controller pods to use the host's network namespace. | false `controller.nginxDebug` | Enables debugging for NGINX. Uses the `nginx-debug` binary. Requires `error-log-level: debug` in the ConfigMap via `controller.config.entries`. | false `controller.logLevel` | The log level of the Ingress Controller. | 1 diff --git a/deployments/helm-chart/values.yaml b/deployments/helm-chart/values.yaml index 6c330b0ff5..9afa25feca 100644 --- a/deployments/helm-chart/values.yaml +++ b/deployments/helm-chart/values.yaml @@ -10,9 +10,7 @@ controller: nginxplus: false # Timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. - # Default is 4000 (default is 20000 instead if enable-app-protect is true) - # If set to 0, default values will be used. - nginxReloadTimeout: 0 + nginxReloadTimeout: 60000 ## Support for App Protect appprotect: diff --git a/docs-web/configuration/global-configuration/command-line-arguments.md b/docs-web/configuration/global-configuration/command-line-arguments.md index 50c5962053..9008d511cc 100644 --- a/docs-web/configuration/global-configuration/command-line-arguments.md +++ b/docs-web/configuration/global-configuration/command-line-arguments.md @@ -128,7 +128,7 @@ Below we describe the available command-line arguments: .. option:: -nginx-reload-timeout - Timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. (default is 4000. Default is 20000 instead if `enable-app-protect` is true) + Timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. (default 60000) .. option:: -nginx-status diff --git a/docs-web/installation/installation-with-helm.md b/docs-web/installation/installation-with-helm.md index 2338a59ef8..971bc0b999 100644 --- a/docs-web/installation/installation-with-helm.md +++ b/docs-web/installation/installation-with-helm.md @@ -150,8 +150,8 @@ The following tables lists the configurable parameters of the NGINX Ingress cont - Deploys the Ingress controller for NGINX Plus. - false * - ``controller.nginxReloadTimeout`` - - The timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. The default is 4000 (or 20000 if `controller.appprotect.enable` is true). If set to 0, the default value will be used. - - 0 + - The timeout in milliseconds which the Ingress Controller will wait for a successful NGINX reload after a change or at the initial start. + - 60000 * - ``controller.appprotect.enable`` - Enables the App Protect module in the Ingress Controller. - false