From e129e4871568346f3740baa0662589716d9193aa Mon Sep 17 00:00:00 2001 From: roman-kiselenko Date: Sat, 9 Nov 2024 15:02:54 +0200 Subject: [PATCH] Log events only related to a valid CNI configuration file. Logs only .conf, .json and .conflist files. Signed-off-by: roman-kiselenko --- pkg/ocicni/ocicni.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index 8ad481b..d5aa072 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -9,6 +9,7 @@ import ( "os" "path" "path/filepath" + "slices" "sort" "strings" "sync" @@ -155,10 +156,13 @@ func (plugin *cniNetworkPlugin) monitorConfDir(ctx context.Context, start *sync. start.Done() plugin.done.Add(1) defer plugin.done.Done() + exts := []string{".conf", ".conflist", ".json"} for { select { case event := <-plugin.watcher.Events: - logrus.Infof("CNI monitoring event %v", event) + if slices.Contains(exts, filepath.Ext(event.Name)) { + logrus.Infof("CNI monitoring event %v", event) + } var defaultDeleted bool createWriteRename := event.Op&fsnotify.Create == fsnotify.Create ||