Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 4 additions & 19 deletions cmd/nginx-ingress/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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() {
Expand Down
37 changes: 0 additions & 37 deletions cmd/nginx-ingress/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"reflect"
"testing"
"time"
)

func TestValidatePort(t *testing.T) {
Expand Down Expand Up @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion deployments/helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions deployments/helm-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Below we describe the available command-line arguments:

.. option:: -nginx-reload-timeout <value>

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

Expand Down
4 changes: 2 additions & 2 deletions docs-web/installation/installation-with-helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down