From 1ccd2fbe9339aa2ed7b4525efb659b8c388bcb41 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Tue, 19 May 2026 21:21:16 +0600 Subject: [PATCH] hub: log LRU registry evictions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cluster Registry pool is a fixed-size LRU (PoolSize=1024). With the embedded descriptor map now copied per registry (see "hub: stop sharing the embedded descriptor map across registries"), eviction no longer corrupts shared state — an evicted registry simply becomes garbage once goroutines release it. But any work that registry had buffered locally (recent RegisterGVR additions, the current cached preferred map, lastRefreshed) is lost, and operators currently have no way to tell the pool is undersized for the workload. Switch to lru.NewWithEvict and log evictions at V(2). The signal is quiet enough to leave on, loud enough to find when grepped. Signed-off-by: Tamal Saha --- hub/pool.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hub/pool.go b/hub/pool.go index d62cd18543..d6ff9fff24 100644 --- a/hub/pool.go +++ b/hub/pool.go @@ -20,6 +20,7 @@ import ( "sync" lru "github.com/hashicorp/golang-lru" + "k8s.io/klog/v2" ) type Pool struct { @@ -31,7 +32,15 @@ type Pool struct { const PoolSize = 1024 // This number should match the max number of concurrent clusters handled func NewPool(kvFactory func() KV) (*Pool, error) { - cache, err := lru.New(PoolSize) + // Log evictions so it's visible when the pool is undersized for the + // workload. With each registry now owning its own KV map (see + // NewKVMapFromKnown), an evicted registry just becomes garbage as + // in-flight goroutines release it — but any work it had buffered + // (e.g. recent RegisterGVR calls) is gone, so frequent evictions are + // worth surfacing. + cache, err := lru.NewWithEvict(PoolSize, func(key, _ interface{}) { + klog.V(2).InfoS("evicted cluster registry from pool", "uid", key) + }) if err != nil { return nil, err }