scheduler: Changed upadteMetrics lock to RLock

This commit is contained in:
Roman Baron
2026-01-18 11:05:13 +02:00
parent 827f5fc9fc
commit 08819ca8f4
2 changed files with 2 additions and 4 deletions

View File

@@ -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)))

View File

@@ -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.