mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
Merge pull request #1642 from marquiz/devel/master-updater-pool-lock
nfd-master: protect node updater pool queueing with a lock
This commit is contained in:
commit
ad96c301a4
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +715,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