Skip to content

Commit 4db3216

Browse files
authored
Merge pull request #1848 from marquiz/devel/leader-elect
nfd-master: proper shutdown of nfd api informers
2 parents 5a5b9e3 + 2bb8a72 commit 4db3216

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/nfd-master/nfd-api-controller.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ func (c *nfdController) updateOneNode(typ string, obj metav1.Object) {
206206
klog.ErrorS(err, "failed to determine node name for object", "type", typ, "object", klog.KObj(obj))
207207
return
208208
}
209-
c.updateOneNodeChan <- nodeName
209+
select {
210+
case c.updateOneNodeChan <- nodeName:
211+
case <-c.stopChan:
212+
}
210213
}
211214

212215
func (c *nfdController) updateAllNodes() {
@@ -217,7 +220,10 @@ func (c *nfdController) updateAllNodes() {
217220
}
218221

219222
func (c *nfdController) updateNodeFeatureGroup(nodeFeatureGroup string) {
220-
c.updateNodeFeatureGroupChan <- nodeFeatureGroup
223+
select {
224+
case c.updateNodeFeatureGroupChan <- nodeFeatureGroup:
225+
case <-c.stopChan:
226+
}
221227
}
222228

223229
func (c *nfdController) updateAllNodeFeatureGroups() {

pkg/nfd-master/nfd-master.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ func (m *nfdMaster) Run() error {
392392

393393
// Update all nodes when the configuration changes
394394
if m.nfdController != nil && nfdfeatures.NFDFeatureGate.Enabled(nfdfeatures.NodeFeatureAPI) {
395-
m.nfdController.updateAllNodesChan <- struct{}{}
395+
m.nfdController.updateAllNodes()
396396
}
397397

398398
case <-m.stop:

0 commit comments

Comments
 (0)