diff --git a/pkg/storage/etcd3/store.go b/pkg/storage/etcd3/store.go index 6fb9fe9aa..7f268bf6c 100644 --- a/pkg/storage/etcd3/store.go +++ b/pkg/storage/etcd3/store.go @@ -186,7 +186,8 @@ func New(c *kubernetes.Client, compactor Compactor, codec runtime.Codec, newFunc newListFunc: newListFunc, compactor: compactor, } - if utilfeature.DefaultFeatureGate.Enabled(features.SizeBasedListCostEstimate) { + // Collecting stats requires properly set resourcePrefix to call getKeys. + if resourcePrefix != "" && utilfeature.DefaultFeatureGate.Enabled(features.SizeBasedListCostEstimate) { stats := newStatsCache(pathPrefix, s.getKeys) s.stats = stats w.stats = stats