diff --git a/pkg/scheduler/backend/cache/cache.go b/pkg/scheduler/backend/cache/cache.go index 48303cce0ce..63d4b57a007 100644 --- a/pkg/scheduler/backend/cache/cache.go +++ b/pkg/scheduler/backend/cache/cache.go @@ -697,8 +697,8 @@ func (cache *cacheImpl) run() { // updateMetrics updates cache size metric values for pods, assumed pods, and nodes func (cache *cacheImpl) updateMetrics() { - cache.mu.Lock() - defer cache.mu.Unlock() + cache.mu.RLock() + defer cache.mu.RUnlock() metrics.CacheSize.WithLabelValues("assumed_pods").Set(float64(len(cache.assumedPods))) metrics.CacheSize.WithLabelValues("pods").Set(float64(len(cache.podStates))) diff --git a/pkg/scheduler/backend/cache/interface.go b/pkg/scheduler/backend/cache/interface.go index 72404ff4600..ad3d7d94d4c 100644 --- a/pkg/scheduler/backend/cache/interface.go +++ b/pkg/scheduler/backend/cache/interface.go @@ -47,13 +47,11 @@ import ( // +--------------------+ Deleted // Forget // -// // Note that "Initial" and "Deleted" pods do not actually exist in cache. // Based on existing use cases, we are making the following assumptions: // - No pod would be assumed twice // - A pod could be added without going through scheduler. In this case, we will see Add but not Assume event. // - If a pod wasn't added, it wouldn't be removed or updated. - type Cache interface { // NodeCount returns the number of nodes in the cache. // DO NOT use outside of tests.