From 1ab88c94e8e3b9ccfe16b2b0dbf26f688be1d4df Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Fri, 25 Aug 2017 08:11:39 +1000 Subject: [PATCH] Call the right cleanup function --- staging/src/k8s.io/client-go/tools/cache/reflector.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/cache/reflector.go b/staging/src/k8s.io/client-go/tools/cache/reflector.go index d0cb2dd152a..4967f98d460 100644 --- a/staging/src/k8s.io/client-go/tools/cache/reflector.go +++ b/staging/src/k8s.io/client-go/tools/cache/reflector.go @@ -239,8 +239,6 @@ func (r *Reflector) resyncChan() (<-chan time.Time, func() bool) { func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { glog.V(3).Infof("Listing and watching %v from %s", r.expectedType, r.name) var resourceVersion string - resyncCh, cleanup := r.resyncChan() - defer cleanup() // Explicitly set "0" as resource version - it's fine for the List() // to be served from cache and potentially be delayed relative to @@ -272,6 +270,10 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { cancelCh := make(chan struct{}) defer close(cancelCh) go func() { + resyncCh, cleanup := r.resyncChan() + defer func() { + cleanup() // Call the last one written into cleanup + }() for { select { case <-resyncCh: