From 097057c51c9a818faa120b909b367b3c29c8841d Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Tue, 7 Nov 2017 12:31:31 +0100 Subject: [PATCH] reflector: exit retry loop on closed stopCh Kubernetes-commit: 8d98c846272b3fb4988bebf54b197d24d8fb3b5f --- tools/cache/reflector.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/cache/reflector.go b/tools/cache/reflector.go index b4865a64..a97b5f98 100644 --- a/tools/cache/reflector.go +++ b/tools/cache/reflector.go @@ -295,6 +295,13 @@ func (r *Reflector) ListAndWatch(stopCh <-chan struct{}) error { }() for { + // give the stopCh a chance to stop the loop, even in case of continue statements further down on errors + select { + case <-stopCh: + return nil + default: + } + timemoutseconds := int64(minWatchTimeout.Seconds() * (rand.Float64() + 1.0)) options = metav1.ListOptions{ ResourceVersion: resourceVersion,