@@ -30,6 +30,7 @@ import (
30
30
31
31
"maps"
32
32
33
+ "github.com/fsnotify/fsnotify"
33
34
"github.com/prometheus/client_golang/prometheus"
34
35
"github.com/prometheus/client_golang/prometheus/promhttp"
35
36
"golang.org/x/net/context"
@@ -55,7 +56,7 @@ import (
55
56
_ "sigs.k8s.io/node-feature-discovery/source/custom"
56
57
_ "sigs.k8s.io/node-feature-discovery/source/fake"
57
58
_ "sigs.k8s.io/node-feature-discovery/source/kernel"
58
- _ "sigs.k8s.io/node-feature-discovery/source/local"
59
+ "sigs.k8s.io/node-feature-discovery/source/local"
59
60
_ "sigs.k8s.io/node-feature-discovery/source/memory"
60
61
_ "sigs.k8s.io/node-feature-discovery/source/network"
61
62
_ "sigs.k8s.io/node-feature-discovery/source/pci"
@@ -121,6 +122,8 @@ type nfdWorker struct {
121
122
k8sClient k8sclient.Interface
122
123
nfdClient nfdclient.Interface
123
124
stop chan struct {} // channel for signaling stop
125
+ fsEvent chan fsnotify.Event
126
+ fsWatcher * fsnotify.Watcher
124
127
featureSources []source.FeatureSource
125
128
labelSources []source.LabelSource
126
129
ownerReference []metav1.OwnerReference
@@ -304,6 +307,13 @@ func (w *nfdWorker) Run() error {
304
307
labelTrigger .Reset (w .config .Core .SleepInterval .Duration )
305
308
defer labelTrigger .Stop ()
306
309
310
+ if s := source .GetFeatureSource ("local" ); s != nil {
311
+ w .fsWatcher = local .FSWatcher
312
+ if w .fsWatcher != nil {
313
+ defer w .fsWatcher .Close ()
314
+ }
315
+ }
316
+
307
317
httpMux := http .NewServeMux ()
308
318
309
319
// Register to metrics server
@@ -341,6 +351,13 @@ func (w *nfdWorker) Run() error {
341
351
return err
342
352
}
343
353
354
+ case event := <- w .fsWatcher .Events :
355
+ if event .Op & fsnotify .Create == fsnotify .Create || event .Op & fsnotify .Write == fsnotify .Write || event .Op & fsnotify .Remove == fsnotify .Remove || event .Op & fsnotify .Rename == fsnotify .Rename || event .Op & fsnotify .Chmod == fsnotify .Chmod {
356
+ err = w .runFeatureDiscovery ()
357
+ if err != nil {
358
+ return err
359
+ }
360
+ }
344
361
case <- w .stop :
345
362
klog .InfoS ("shutting down nfd-worker" )
346
363
return nil
0 commit comments