From 5dad27cf7ec0dbeecbe13fbcc3095b54a0f0f925 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 3 Jan 2018 00:28:41 +0000 Subject: [PATCH] permit setting probe.kubernetes.interval to 0 ...which is useful if we want to disable periodic fetching of all objects. Previously the interval was also used to set the initial backoff of the reconnect logic. A zero value there would result in _no_ backoff. So instead we now just use the default, which is 10s which also happens to be the default probe.kubernetes.interval, so there is no change in behaviour for the stock settings. --- probe/kubernetes/client.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/probe/kubernetes/client.go b/probe/kubernetes/client.go index eae963e50a..c629ae0e03 100644 --- a/probe/kubernetes/client.go +++ b/probe/kubernetes/client.go @@ -66,7 +66,7 @@ type client struct { // runReflectorUntil runs cache.Reflector#ListAndWatch in an endless loop. // Errors are logged and retried with exponential backoff. -func runReflectorUntil(r *cache.Reflector, resyncPeriod time.Duration, stopCh <-chan struct{}, msg string) { +func runReflectorUntil(r *cache.Reflector, stopCh <-chan struct{}, msg string) { listAndWatch := func() (bool, error) { select { case <-stopCh: @@ -77,7 +77,6 @@ func runReflectorUntil(r *cache.Reflector, resyncPeriod time.Duration, stopCh <- } } bo := backoff.New(listAndWatch, fmt.Sprintf("Kubernetes reflector (%s)", msg)) - bo.SetInitialBackoff(resyncPeriod) bo.SetMaxBackoff(5 * time.Minute) go bo.Start() } @@ -192,7 +191,7 @@ func (c *client) setupStore(kclient cache.Getter, resource string, itemType inte if store == nil { store = cache.NewStore(cache.MetaNamespaceKeyFunc) } - runReflectorUntil(cache.NewReflector(lw, itemType, store, c.resyncPeriod), c.resyncPeriod, c.quit, resource) + runReflectorUntil(cache.NewReflector(lw, itemType, store, c.resyncPeriod), c.quit, resource) return store }