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.
This commit is contained in:
Matthias Radestock
2018-01-03 00:28:41 +00:00
parent f9f0487fdc
commit 5dad27cf7e

View File

@@ -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
}