Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfd-master: protect node updater pool queueing with a lock #1642

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/nfd-master/nfd-master.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
}
} else {
for nodeName := range updateNodes {
m.nodeUpdaterPool.queue.Add(nodeName)
m.nodeUpdaterPool.addNode(nodeName)

Check warning on line 445 in pkg/nfd-master/nfd-master.go

View check run for this annotation

Codecov / codecov/patch

pkg/nfd-master/nfd-master.go#L445

Added line #L445 was not covered by tests
}
}

Expand Down Expand Up @@ -710,7 +710,7 @@
}

for _, node := range nodes.Items {
m.nodeUpdaterPool.queue.Add(node.Name)
m.nodeUpdaterPool.addNode(node.Name)

Check warning on line 713 in pkg/nfd-master/nfd-master.go

View check run for this annotation

Codecov / codecov/patch

pkg/nfd-master/nfd-master.go#L713

Added line #L713 was not covered by tests
}

return nil
Expand Down
8 changes: 7 additions & 1 deletion pkg/nfd-master/node-updater-pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

type nodeUpdaterPool struct {
queue workqueue.RateLimitingInterface
sync.Mutex
sync.RWMutex

wg sync.WaitGroup
nfdMaster *nfdMaster
Expand Down Expand Up @@ -114,3 +114,9 @@
u.queue.ShutDown()
u.wg.Wait()
}

func (u *nodeUpdaterPool) addNode(nodeName string) {
u.RLock()
defer u.RUnlock()
u.queue.Add(nodeName)

Check warning on line 121 in pkg/nfd-master/node-updater-pool.go

View check run for this annotation

Codecov / codecov/patch

pkg/nfd-master/node-updater-pool.go#L118-L121

Added lines #L118 - L121 were not covered by tests
}