From 0129dede894b90789e7f03ea91a9578ef5741994 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Sat, 20 Apr 2019 11:05:55 -0700 Subject: [PATCH] Use read lock for QuotaMonitor#IsSynced --- pkg/controller/resourcequota/resource_quota_monitor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/controller/resourcequota/resource_quota_monitor.go b/pkg/controller/resourcequota/resource_quota_monitor.go index 34fde92da87..df92b103688 100644 --- a/pkg/controller/resourcequota/resource_quota_monitor.go +++ b/pkg/controller/resourcequota/resource_quota_monitor.go @@ -69,7 +69,7 @@ type event struct { type QuotaMonitor struct { // each monitor list/watches a resource and determines if we should replenish quota monitors monitors - monitorLock sync.Mutex + monitorLock sync.RWMutex // informersStarted is closed after after all of the controllers have been initialized and are running. // After that it is safe to start them here, before that it is not. informersStarted <-chan struct{} @@ -280,8 +280,8 @@ func (qm *QuotaMonitor) StartMonitors() { // true at one time, and then later return false if all monitors were // reconstructed. func (qm *QuotaMonitor) IsSynced() bool { - qm.monitorLock.Lock() - defer qm.monitorLock.Unlock() + qm.monitorLock.RLock() + defer qm.monitorLock.RUnlock() if len(qm.monitors) == 0 { klog.V(4).Info("quota monitor not synced: no monitors")