Skip to content

Commit

Permalink
Merge pull request #1167 from PiotrProkop/fix-reactive-updates
Browse files Browse the repository at this point in the history
nfd-topology-updater: fix wrong kubelet_internal_checkpoint path and compare basename to full path
  • Loading branch information
k8s-ci-robot authored Apr 24, 2023
2 parents 2356223 + 5a9a121 commit 54bd4c5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/nfd-topology-updater/kubeletnotifier/kubeletnotifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package kubeletnotifier

import (
"fmt"
"path"
"time"

"k8s.io/apimachinery/pkg/util/sets"
Expand All @@ -31,6 +32,8 @@ type EventType string
const (
IntervalBased EventType = "intervalBased"
FSUpdate EventType = "fsUpdate"

devicePluginsDirName = "device-plugins"
)

var stateFiles = sets.NewString(
Expand All @@ -51,7 +54,8 @@ type Info struct {
}

func New(sleepInterval time.Duration, dest chan<- Info, kubeletStateDir string) (*Notifier, error) {
ch, err := createFSWatcherEvent([]string{kubeletStateDir})
devicePluginsDir := path.Join(kubeletStateDir, devicePluginsDirName)
ch, err := createFSWatcherEvent([]string{kubeletStateDir, devicePluginsDir})
if err != nil {
return nil, err
}
Expand All @@ -77,8 +81,9 @@ func (n *Notifier) Run() {
n.dest <- i

case e := <-n.fsEvent:
klog.V(5).Infof("fsnotify event from file %q: %q received", e.Name, e.Op)
if stateFiles.Has(e.Name) {
basename := path.Base(e.Name)
klog.V(5).Infof("fsnotify event from file %q: %q received", basename, e.Op)
if stateFiles.Has(basename) {
i := Info{Event: FSUpdate}
n.dest <- i
}
Expand Down

0 comments on commit 54bd4c5

Please sign in to comment.