From a20abdb1f425b215ce969ef7114281741fce249d Mon Sep 17 00:00:00 2001 From: Lukasz Szaszkiewicz Date: Mon, 3 Jun 2024 10:26:50 +0200 Subject: [PATCH] cacher: dispatchEvents is synced to watchCache.listResourceVersion The internal informer populates the RV as soon as it conducts The first successful sync with the underlying store. The cache must wait until this first sync is completed to be deemed ready. Since we cannot send a bookmark when the lastProcessedResourceVersion is 0, we poll aggressively for the first list RV before entering the dispatch loop. --- staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go | 4 ++-- .../src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index bbb510fcb73..2922f4804ee 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -912,10 +912,10 @@ func (c *Cacher) dispatchEvents() { // The first successful sync with the underlying store. // The cache must wait until this first sync is completed to be deemed ready. // Since we cannot send a bookmark when the lastProcessedResourceVersion is 0, - // we poll aggressively for the first RV before entering the dispatch loop. + // we poll aggressively for the first list RV before entering the dispatch loop. lastProcessedResourceVersion := uint64(0) if err := wait.PollUntilContextCancel(wait.ContextForChannel(c.stopCh), 10*time.Millisecond, true, func(_ context.Context) (bool, error) { - if rv := c.watchCache.getResourceVersion(); rv != 0 { + if rv := c.watchCache.getListResourceVersion(); rv != 0 { lastProcessedResourceVersion = rv return true, nil } diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go index 1f65be9705e..642619ff202 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/watch_cache.go @@ -644,10 +644,10 @@ func (w *watchCache) Resync() error { return nil } -func (w *watchCache) getResourceVersion() uint64 { +func (w *watchCache) getListResourceVersion() uint64 { w.RLock() defer w.RUnlock() - return w.resourceVersion + return w.listResourceVersion } func (w *watchCache) currentCapacity() int {