Flip to using a positive behaviour flag instead of negative

Signed-off-by: Rafael da Fonseca <rafael.fonseca@wildlifestudios.com>
This commit is contained in:
Rafael da Fonseca 2024-01-22 12:07:03 +00:00
parent 1e20a00589
commit 1b8f98397a
6 changed files with 15 additions and 12 deletions

View file

@ -14,6 +14,7 @@ metadata:
namespace: {{ include "ingress-nginx.namespace" . }} namespace: {{ include "ingress-nginx.namespace" . }}
data: data:
allow-snippet-annotations: "{{ .Values.controller.allowSnippetAnnotations }}" allow-snippet-annotations: "{{ .Values.controller.allowSnippetAnnotations }}"
enable-serial-reloads: "{{ .Values.controller.enableSerialReloads }}"
{{- if .Values.controller.addHeaders }} {{- if .Values.controller.addHeaders }}
add-headers: {{ include "ingress-nginx.namespace" . }}/{{ include "ingress-nginx.fullname" . }}-custom-add-headers add-headers: {{ include "ingress-nginx.namespace" . }}/{{ include "ingress-nginx.fullname" . }}-custom-add-headers
{{- end }} {{- end }}

View file

@ -88,6 +88,8 @@ controller:
# when users add those annotations. # when users add those annotations.
# Global snippets in ConfigMap are still respected # Global snippets in ConfigMap are still respected
allowSnippetAnnotations: false allowSnippetAnnotations: false
# -- This configuration defines if NGINX workers should reload serially instead of concurrently when multiple changes that require reloads are queued
enableSerialReloads: false
# -- Required for use with CNI based kubernetes installations (such as ones set up by kubeadm), # -- Required for use with CNI based kubernetes installations (such as ones set up by kubeadm),
# since CNI and hostport don't mix yet. Can be deprecated once https://github.com/kubernetes/kubernetes/issues/23920 # since CNI and hostport don't mix yet. Can be deprecated once https://github.com/kubernetes/kubernetes/issues/23920
# is merged # is merged

View file

@ -114,7 +114,7 @@ The following table shows a configuration option's name, type, and the default v
|[worker-processes](#worker-processes)|string|`<Number of CPUs>`|| |[worker-processes](#worker-processes)|string|`<Number of CPUs>`||
|[worker-cpu-affinity](#worker-cpu-affinity)|string|""|| |[worker-cpu-affinity](#worker-cpu-affinity)|string|""||
|[worker-shutdown-timeout](#worker-shutdown-timeout)|string|"240s"|| |[worker-shutdown-timeout](#worker-shutdown-timeout)|string|"240s"||
|[concurrently-reload-worker-processes](#concurrently-reload-worker-processes)|bool|"true"|| |[enable-serial-reloads](#enable-serial-reloads)|bool|"false"||
|[load-balance](#load-balance)|string|"round_robin"|| |[load-balance](#load-balance)|string|"round_robin"||
|[variables-hash-bucket-size](#variables-hash-bucket-size)|int|128|| |[variables-hash-bucket-size](#variables-hash-bucket-size)|int|128||
|[variables-hash-max-size](#variables-hash-max-size)|int|2048|| |[variables-hash-max-size](#variables-hash-max-size)|int|2048||

View file

@ -479,7 +479,7 @@ type Configuration struct {
// With this setting on false, configuration changes in the queue will be re-queued with an exponential backoff, until the number of worker process is the expected value. // With this setting on false, configuration changes in the queue will be re-queued with an exponential backoff, until the number of worker process is the expected value.
// By default new worker processes are spawned every time there's a change that cannot be applied dynamically with no upper limit to the number of running workers // By default new worker processes are spawned every time there's a change that cannot be applied dynamically with no upper limit to the number of running workers
// http://nginx.org/en/docs/ngx_core_module.html#worker_processes // http://nginx.org/en/docs/ngx_core_module.html#worker_processes
ConcurrentlyReloadWorkers bool `json:"concurrently-reload-worker-processes,omitempty"` WorkerSerialReloads bool `json:"enable-serial-reloads,omitempty"`
// Defines a timeout for a graceful shutdown of worker processes // Defines a timeout for a graceful shutdown of worker processes
// http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout // http://nginx.org/en/docs/ngx_core_module.html#worker_shutdown_timeout
@ -849,7 +849,7 @@ func NewDefault() Configuration {
UseGzip: false, UseGzip: false,
UseGeoIP2: false, UseGeoIP2: false,
WorkerProcesses: strconv.Itoa(runtime.NumCPU()), WorkerProcesses: strconv.Itoa(runtime.NumCPU()),
ConcurrentlyReloadWorkers: true, WorkerSerialReloads: false,
WorkerShutdownTimeout: "240s", WorkerShutdownTimeout: "240s",
VariablesHashBucketSize: 256, VariablesHashBucketSize: 256,
VariablesHashMaxSize: 2048, VariablesHashMaxSize: 2048,

View file

@ -672,8 +672,8 @@ Error: %v
// //
//nolint:gocritic // the cfg shouldn't be changed, and shouldn't be mutated by other processes while being rendered. //nolint:gocritic // the cfg shouldn't be changed, and shouldn't be mutated by other processes while being rendered.
func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error { func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
concurrentlyReloadWorkers := n.store.GetBackendConfiguration().ConcurrentlyReloadWorkers workerSerialReloads := n.store.GetBackendConfiguration().WorkerSerialReloads
if !concurrentlyReloadWorkers && n.workersReloading { if workerSerialReloads && n.workersReloading {
return errors.New("worker reload already in progress, requeuing reload") return errors.New("worker reload already in progress, requeuing reload")
} }
@ -743,7 +743,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
} }
// Reload status checking runs in a separate goroutine to avoid blocking the sync queue // Reload status checking runs in a separate goroutine to avoid blocking the sync queue
if !concurrentlyReloadWorkers { if workerSerialReloads {
go n.awaitWorkersReload() go n.awaitWorkersReload()
} }

View file

@ -67,7 +67,7 @@ const (
luaSharedDictsKey = "lua-shared-dicts" luaSharedDictsKey = "lua-shared-dicts"
plugins = "plugins" plugins = "plugins"
debugConnections = "debug-connections" debugConnections = "debug-connections"
concurrentlyReloadWorkers = "concurrently-reload-worker-processes" workerSerialReloads = "enable-serial-reloads"
) )
var ( var (
@ -386,15 +386,15 @@ func ReadConfig(src map[string]string) config.Configuration {
delete(conf, workerProcesses) delete(conf, workerProcesses)
} }
if val, ok := conf[concurrentlyReloadWorkers]; ok { if val, ok := conf[workerSerialReloads]; ok {
boolVal, err := strconv.ParseBool(val) boolVal, err := strconv.ParseBool(val)
if err != nil { if err != nil {
to.ConcurrentlyReloadWorkers = true to.WorkerSerialReloads = false
klog.Warningf("failed to parse concurrently-reload-worker-processes setting, valid values are true or false, found %s", val) klog.Warningf("failed to parse enable-serial-reloads setting, valid values are true or false, found %s", val)
} else { } else {
to.ConcurrentlyReloadWorkers = boolVal to.WorkerSerialReloads = boolVal
} }
delete(conf, concurrentlyReloadWorkers) delete(conf, workerSerialReloads)
} }
if val, ok := conf[plugins]; ok { if val, ok := conf[plugins]; ok {