mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-16 21:38:23 +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 {
|
} else {
|
||||||
for nodeName := range updateNodes {
|
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 {
|
for _, node := range nodes.Items {
|
||||||
m.nodeUpdaterPool.queue.Add(node.Name)
|
m.nodeUpdaterPool.addNode(node.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
type nodeUpdaterPool struct {
|
type nodeUpdaterPool struct {
|
||||||
queue workqueue.RateLimitingInterface
|
queue workqueue.RateLimitingInterface
|
||||||
sync.Mutex
|
sync.RWMutex
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
nfdMaster *nfdMaster
|
nfdMaster *nfdMaster
|
||||||
|
@ -114,3 +114,9 @@ func (u *nodeUpdaterPool) stop() {
|
||||||
u.queue.ShutDown()
|
u.queue.ShutDown()
|
||||||
u.wg.Wait()
|
u.wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *nodeUpdaterPool) addNode(nodeName string) {
|
||||||
|
u.RLock()
|
||||||
|
defer u.RUnlock()
|
||||||
|
u.queue.Add(nodeName)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue