mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-23 10:58:42 +00:00
Track run status explicitly rather than non-nil check on stopCh
This commit is contained in:
@@ -74,13 +74,14 @@ type QuotaMonitor struct {
|
||||
// After that it is safe to start them here, before that it is not.
|
||||
informersStarted <-chan struct{}
|
||||
|
||||
// stopCh drives shutdown. If it is nil, it indicates that Run() has not been
|
||||
// called yet. If it is non-nil, then when closed it indicates everything
|
||||
// should shut down.
|
||||
//
|
||||
// stopCh drives shutdown. When a receive from it unblocks, monitors will shut down.
|
||||
// This channel is also protected by monitorLock.
|
||||
stopCh <-chan struct{}
|
||||
|
||||
// running tracks whether Run() has been called.
|
||||
// it is protected by monitorLock.
|
||||
running bool
|
||||
|
||||
// monitors are the producer of the resourceChanges queue
|
||||
resourceChanges workqueue.RateLimitingInterface
|
||||
|
||||
@@ -241,7 +242,7 @@ func (qm *QuotaMonitor) startMonitors() {
|
||||
qm.monitorLock.Lock()
|
||||
defer qm.monitorLock.Unlock()
|
||||
|
||||
if qm.stopCh == nil {
|
||||
if !qm.running {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -291,6 +292,7 @@ func (qm *QuotaMonitor) Run(stopCh <-chan struct{}) {
|
||||
// Set up the stop channel.
|
||||
qm.monitorLock.Lock()
|
||||
qm.stopCh = stopCh
|
||||
qm.running = true
|
||||
qm.monitorLock.Unlock()
|
||||
|
||||
// Start monitors and begin change processing until the stop channel is
|
||||
|
Reference in New Issue
Block a user