mirror of https://github.com/k3s-io/k3s
Merge pull request #76868 from tedyu/res-quota-mon-read
Use read lock for QuotaMonitor#IsSyncedk3s-v1.15.3
commit
b03e4bbc22
|
@ -69,7 +69,7 @@ type event struct {
|
||||||
type QuotaMonitor struct {
|
type QuotaMonitor struct {
|
||||||
// each monitor list/watches a resource and determines if we should replenish quota
|
// each monitor list/watches a resource and determines if we should replenish quota
|
||||||
monitors monitors
|
monitors monitors
|
||||||
monitorLock sync.Mutex
|
monitorLock sync.RWMutex
|
||||||
// informersStarted is closed after after all of the controllers have been initialized and are running.
|
// 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.
|
// After that it is safe to start them here, before that it is not.
|
||||||
informersStarted <-chan struct{}
|
informersStarted <-chan struct{}
|
||||||
|
@ -280,8 +280,8 @@ func (qm *QuotaMonitor) StartMonitors() {
|
||||||
// true at one time, and then later return false if all monitors were
|
// true at one time, and then later return false if all monitors were
|
||||||
// reconstructed.
|
// reconstructed.
|
||||||
func (qm *QuotaMonitor) IsSynced() bool {
|
func (qm *QuotaMonitor) IsSynced() bool {
|
||||||
qm.monitorLock.Lock()
|
qm.monitorLock.RLock()
|
||||||
defer qm.monitorLock.Unlock()
|
defer qm.monitorLock.RUnlock()
|
||||||
|
|
||||||
if len(qm.monitors) == 0 {
|
if len(qm.monitors) == 0 {
|
||||||
klog.V(4).Info("quota monitor not synced: no monitors")
|
klog.V(4).Info("quota monitor not synced: no monitors")
|
||||||
|
|
Loading…
Reference in New Issue