mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
nfd-master: protect node updater pool queueing with a lock
Prevents races when (re-)starting the queue. There are no reports on issues related to this (and I haven't come up with any actual failure path in the current code) but better to be safe and follow the best practices.
This commit is contained in:
parent
137f18b5b3
commit
bce446c5b6
2 changed files with 9 additions and 3 deletions
|
@ -442,7 +442,7 @@ func (m *nfdMaster) nfdAPIUpdateHandler() {
|
|||
}
|
||||
} else {
|
||||
for nodeName := range updateNodes {
|
||||
m.nodeUpdaterPool.queue.Add(nodeName)
|
||||
m.nodeUpdaterPool.addNode(nodeName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,7 +710,7 @@ func (m *nfdMaster) nfdAPIUpdateAllNodes() error {
|
|||
}
|
||||
|
||||
for _, node := range nodes.Items {
|
||||
m.nodeUpdaterPool.queue.Add(node.Name)
|
||||
m.nodeUpdaterPool.addNode(node.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
type nodeUpdaterPool struct {
|
||||
queue workqueue.RateLimitingInterface
|
||||
sync.Mutex
|
||||
sync.RWMutex
|
||||
|
||||
wg sync.WaitGroup
|
||||
nfdMaster *nfdMaster
|
||||
|
@ -114,3 +114,9 @@ func (u *nodeUpdaterPool) stop() {
|
|||
u.queue.ShutDown()
|
||||
u.wg.Wait()
|
||||
}
|
||||
|
||||
func (u *nodeUpdaterPool) addNode(nodeName string) {
|
||||
u.RLock()
|
||||
defer u.RUnlock()
|
||||
u.queue.Add(nodeName)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue