Skip to content

Commit 0129ded

Browse files
tedyuyutedz
authored andcommitted
Use read lock for QuotaMonitor#IsSynced
1 parent cee320a commit 0129ded

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/controller/resourcequota/resource_quota_monitor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type event struct {
6969
type QuotaMonitor struct {
7070
// each monitor list/watches a resource and determines if we should replenish quota
7171
monitors monitors
72-
monitorLock sync.Mutex
72+
monitorLock sync.RWMutex
7373
// informersStarted is closed after after all of the controllers have been initialized and are running.
7474
// After that it is safe to start them here, before that it is not.
7575
informersStarted <-chan struct{}
@@ -280,8 +280,8 @@ func (qm *QuotaMonitor) StartMonitors() {
280280
// true at one time, and then later return false if all monitors were
281281
// reconstructed.
282282
func (qm *QuotaMonitor) IsSynced() bool {
283-
qm.monitorLock.Lock()
284-
defer qm.monitorLock.Unlock()
283+
qm.monitorLock.RLock()
284+
defer qm.monitorLock.RUnlock()
285285

286286
if len(qm.monitors) == 0 {
287287
klog.V(4).Info("quota monitor not synced: no monitors")

0 commit comments

Comments
 (0)