mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
nfd-topology-updater: fix kubelet state file notifier
- kubelet_internal_checkpoint file is in /var/lib/kubelet/device-plugins not /var/lib/kubelet fsWatcher doesn't watch dirs recursively - e.Name returned from fsWatcher events is a full path not a basename Signed-off-by: pprokop <pprokop@nvidia.com>
This commit is contained in:
parent
95d243aa38
commit
85a88abdd3
1 changed files with 8 additions and 3 deletions
|
@ -18,6 +18,7 @@ package kubeletnotifier
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -31,6 +32,8 @@ type EventType string
|
|||
const (
|
||||
IntervalBased EventType = "intervalBased"
|
||||
FSUpdate EventType = "fsUpdate"
|
||||
|
||||
devicePluginsDirName = "device-plugins"
|
||||
)
|
||||
|
||||
var stateFiles = sets.NewString(
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue