From b661a2b209685acb57d6d0a520d9a6df4b17e59e 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index 8ad481b..3d68f83 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -155,10 +155,16 @@ func (plugin *cniNetworkPlugin) monitorConfDir(ctx context.Context, start *sync. start.Done() plugin.done.Add(1) defer plugin.done.Done() + exts := map[string]bool{} + for _, ext := range []string{".conf", ".conflist", ".json"} { + exts[ext] = true + } for { select { case event := <-plugin.watcher.Events: - logrus.Infof("CNI monitoring event %v", event) + if exts[filepath.Ext(event.Name)] { + logrus.Infof("CNI monitoring event %v", event) + } var defaultDeleted bool createWriteRename := event.Op&fsnotify.Create == fsnotify.Create ||