From fed8dfe7363c83b52e2795197225118b0df28d9c Mon Sep 17 00:00:00 2001 From: Sohan Kunkerkar Date: Tue, 23 Jul 2024 10:55:16 -0400 Subject: [PATCH] dynamiccertificates: denoise Kubelet logs by skipping removal of non-existent file watchers This commit updates the DynamicFileCAContent controller to skip the removal of non-existent file watchers. Previously, the controller attempted to remove a file watch even if it didn't exist, which resulted in a flood of error messages being logged in the Kubelet logs. Signed-off-by: Sohan Kunkerkar Kubernetes-commit: 17ad4b39f8b6b299d20fb94f99083ea84083b6b2 --- pkg/server/dynamiccertificates/dynamic_cafile_content.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/server/dynamiccertificates/dynamic_cafile_content.go b/pkg/server/dynamiccertificates/dynamic_cafile_content.go index 1f32adf9e..0fcf82bd0 100644 --- a/pkg/server/dynamiccertificates/dynamic_cafile_content.go +++ b/pkg/server/dynamiccertificates/dynamic_cafile_content.go @@ -20,6 +20,7 @@ import ( "bytes" "context" "crypto/x509" + "errors" "fmt" "os" "sync/atomic" @@ -210,7 +211,7 @@ func (c *DynamicFileCAContent) handleWatchEvent(e fsnotify.Event, w *fsnotify.Wa if !e.Has(fsnotify.Remove) && !e.Has(fsnotify.Rename) { return nil } - if err := w.Remove(c.filename); err != nil { + if err := w.Remove(c.filename); err != nil && !errors.Is(err, fsnotify.ErrNonExistentWatch) { klog.InfoS("Failed to remove file watch, it may have been deleted", "file", c.filename, "err", err) } if err := w.Add(c.filename); err != nil {