Skip to content

Commit ba4cebb

Browse files
committed
nfd-master: stop node-updater pool before reconfiguring api-controller
Prevents potential race between node-updater pool and the api-controller when re-configuring nfd-master. Reconfiguration causes a new api-controller instance to be created so nfd api lister might change in the midst of processing a node update (if the pool was running). No actual issues related to this have been identified but races (like this) should still be avoided.
1 parent 31a56ac commit ba4cebb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg/nfd-master/nfd-master.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ func (m *nfdMaster) Run() error {
350350
return err
351351
}
352352

353+
// Stop the nodeUpdaterPool so that no node updates are underway
354+
// while we reconfigure the NFD API controller (including the
355+
// listers) below
356+
m.nodeUpdaterPool.stop()
357+
353358
// restart NFD API controller
354359
if m.nfdController != nil {
355360
klog.InfoS("stopping the nfd api controller")
@@ -361,13 +366,13 @@ func (m *nfdMaster) Run() error {
361366
return nil
362367
}
363368
}
369+
// Restart the nodeUpdaterPool
370+
m.nodeUpdaterPool.start(m.config.NfdApiParallelism)
371+
364372
// Update all nodes when the configuration changes
365373
if m.nfdController != nil && features.NFDFeatureGate.Enabled(features.NodeFeatureAPI) {
366374
m.nfdController.updateAllNodesChan <- struct{}{}
367375
}
368-
// Restart the node updater pool
369-
m.nodeUpdaterPool.stop()
370-
m.nodeUpdaterPool.start(m.config.NfdApiParallelism)
371376

372377
case <-m.stop:
373378
klog.InfoS("shutting down nfd-master")

0 commit comments

Comments
 (0)