diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index 0df5409f4..b81734154 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -202,8 +202,11 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro } for _, f := range filesToWatch { + // This redeclaration is necessary for the closure to get the correct value for the iteration in go versions <1.22 + // See https://go.dev/blog/loopvar-preview + f := f _, err = file.NewFileWatcher(f, func() { - klog.InfoS("File changed detected. Reloading NGINX", "path", f) + klog.InfoS("File change detected. Reloading NGINX", "path", f) n.syncQueue.EnqueueTask(task.GetDummyObject("file-change")) }) if err != nil {