Merge pull request #37085 from gmarek/rv

Automatic merge from submit-queue

Add fast-path for Listing with ResourceVersion=0

We slightly change the behavior, but we keep the current contract, so release note is not needed.

cc @saad-ali
This commit is contained in:
Kubernetes Submit Queue 2016-11-18 09:45:11 -08:00 committed by GitHub
commit 9d4f94dcec

View File

@ -283,10 +283,13 @@ func (w *watchCache) waitUntilFreshAndBlock(resourceVersion uint64, trace *util.
// WaitUntilFreshAndList returns list of pointers to <storeElement> 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
}