fix path in file changed detected message (#11286)

* fix path in file changed detected message

Signed-off-by: Tom Hayward <thayward@infoblox.com>

* fix typo in log message

* explain code per review comments

---------

Signed-off-by: Tom Hayward <thayward@infoblox.com>
Co-authored-by: Tom Hayward <thayward@infoblox.com>
This commit is contained in:
k8s-infra-cherrypick-robot 2024-04-19 09:56:22 -07:00 committed by GitHub
parent 6fbd58353f
commit 1a7f674422
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {