From e1542300aead4bb60806e8decc655321f5b02057 Mon Sep 17 00:00:00 2001 From: gmarek Date: Fri, 18 Nov 2016 13:54:10 +0100 Subject: [PATCH] Add fast-path for Listing with ResourceVersion=0 --- pkg/storage/watch_cache.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/storage/watch_cache.go b/pkg/storage/watch_cache.go index 54c1ccd8fd1..767899a2f9e 100644 --- a/pkg/storage/watch_cache.go +++ b/pkg/storage/watch_cache.go @@ -283,10 +283,13 @@ func (w *watchCache) waitUntilFreshAndBlock(resourceVersion uint64, trace *util. // WaitUntilFreshAndList returns list of pointers to objects. func (w *watchCache) WaitUntilFreshAndList(resourceVersion uint64, trace *util.Trace) ([]interface{}, uint64, error) { - err := w.waitUntilFreshAndBlock(resourceVersion, trace) - defer w.RUnlock() - if err != nil { - return nil, 0, err + // If resourceVersion == 0 we'll return the data that we currently have in cache. + if resourceVersion != 0 { + err := w.waitUntilFreshAndBlock(resourceVersion, trace) + defer w.RUnlock() + if err != nil { + return nil, 0, err + } } return w.store.List(), w.resourceVersion, nil }