1
0
Fork 0
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:
Kubernetes Prow Robot 2024-04-05 03:31:10 -07:00 committed by GitHub
commit ad96c301a4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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)
}