Skip to content

Commit

Permalink
Log events only related to a valid CNI configuration file.
Browse files Browse the repository at this point in the history
Logs only .conf, .json and .conflist files.

Signed-off-by: roman-kiselenko <roman.kiselenko.dev@gmail.com>
  • Loading branch information
roman-kiselenko committed Nov 16, 2024
1 parent 94d9529 commit e129e48
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/ocicni/ocicni.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path"
"path/filepath"
"slices"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -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 ||
Expand Down

0 comments on commit e129e48

Please sign in to comment.