diff --git a/provider/consul_catalog.go b/provider/consul_catalog.go index cdf791c22..a62edad1b 100644 --- a/provider/consul_catalog.go +++ b/provider/consul_catalog.go @@ -13,6 +13,7 @@ import ( "github.com/cenkalti/backoff" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" + "github.com/containous/traefik/utils" "github.com/hashicorp/consul/api" ) @@ -320,7 +321,7 @@ func (provider *ConsulCatalog) Provide(configurationChan chan<- types.ConfigMess worker := func() error { return provider.watch(configurationChan, stop) } - err := backoff.RetryNotify(worker, backoff.NewExponentialBackOff(), notify) + err := utils.RetryNotifyJob(worker, backoff.NewExponentialBackOff(), notify) if err != nil { log.Errorf("Cannot connect to consul server %+v", err) } diff --git a/provider/docker.go b/provider/docker.go index baea5cf9c..fbae1c7fa 100644 --- a/provider/docker.go +++ b/provider/docker.go @@ -15,6 +15,7 @@ import ( "github.com/cenkalti/backoff" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" + "github.com/containous/traefik/utils" "github.com/containous/traefik/version" "github.com/docker/engine-api/client" dockertypes "github.com/docker/engine-api/types" @@ -139,7 +140,7 @@ func (provider *Docker) Provide(configurationChan chan<- types.ConfigMessage, po notify := func(err error, time time.Duration) { log.Errorf("Docker connection error %+v, retrying in %s", err, time) } - err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) + err := utils.RetryNotifyJob(operation, backoff.NewExponentialBackOff(), notify) if err != nil { log.Errorf("Cannot connect to docker server %+v", err) } diff --git a/provider/kubernetes.go b/provider/kubernetes.go index aaeba1fec..b10b5480e 100644 --- a/provider/kubernetes.go +++ b/provider/kubernetes.go @@ -7,7 +7,7 @@ import ( "github.com/containous/traefik/provider/k8s" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" - "io" + "github.com/containous/traefik/utils" "io/ioutil" "os" "reflect" @@ -104,7 +104,7 @@ func (provider *Kubernetes) Provide(configurationChan chan<- types.ConfigMessage for { stopWatch := make(chan bool, 5) defer close(stopWatch) - log.Debugf("Using lable selector: %s", provider.LabelSelector) + log.Debugf("Using label selector: '%s'", provider.LabelSelector) eventsChan, errEventsChan, err := k8sClient.WatchAll(provider.LabelSelector, stopWatch) if err != nil { log.Errorf("Error watching kubernetes events: %v", err) @@ -116,18 +116,13 @@ func (provider *Kubernetes) Provide(configurationChan chan<- types.ConfigMessage return nil } } - Watch: for { select { case <-stop: stopWatch <- true return nil - case err, ok := <-errEventsChan: + case err, _ := <-errEventsChan: stopWatch <- true - if ok && strings.Contains(err.Error(), io.EOF.Error()) { - // edge case, kubernetes long-polling disconnection - break Watch - } return err case event := <-eventsChan: log.Debugf("Received event from kubernetes %+v", event) @@ -152,7 +147,7 @@ func (provider *Kubernetes) Provide(configurationChan chan<- types.ConfigMessage notify := func(err error, time time.Duration) { log.Errorf("Kubernetes connection error %+v, retrying in %s", err, time) } - err := backoff.RetryNotify(operation, backOff, notify) + err := utils.RetryNotifyJob(operation, backOff, notify) if err != nil { log.Errorf("Cannot connect to Kubernetes server %+v", err) } diff --git a/provider/kv.go b/provider/kv.go index 332f761dc..ee874105f 100644 --- a/provider/kv.go +++ b/provider/kv.go @@ -13,6 +13,7 @@ import ( "github.com/cenkalti/backoff" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" + "github.com/containous/traefik/utils" "github.com/docker/libkv" "github.com/docker/libkv/store" ) @@ -75,7 +76,7 @@ func (provider *Kv) watchKv(configurationChan chan<- types.ConfigMessage, prefix notify := func(err error, time time.Duration) { log.Errorf("KV connection error: %+v, retrying in %s", err, time) } - err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) + err := utils.RetryNotifyJob(operation, backoff.NewExponentialBackOff(), notify) if err != nil { return fmt.Errorf("Cannot connect to KV server: %v", err) } @@ -105,7 +106,7 @@ func (provider *Kv) provide(configurationChan chan<- types.ConfigMessage, pool * notify := func(err error, time time.Duration) { log.Errorf("KV connection error: %+v, retrying in %s", err, time) } - err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) + err := utils.RetryNotifyJob(operation, backoff.NewExponentialBackOff(), notify) if err != nil { return fmt.Errorf("Cannot connect to KV server: %v", err) } diff --git a/provider/marathon.go b/provider/marathon.go index d33186e7e..606608b1f 100644 --- a/provider/marathon.go +++ b/provider/marathon.go @@ -13,6 +13,7 @@ import ( "github.com/cenkalti/backoff" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" + "github.com/containous/traefik/utils" "github.com/gambol99/go-marathon" "net/http" "time" @@ -108,7 +109,7 @@ func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage, notify := func(err error, time time.Duration) { log.Errorf("Marathon connection error %+v, retrying in %s", err, time) } - err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) + err := utils.RetryNotifyJob(operation, backoff.NewExponentialBackOff(), notify) if err != nil { log.Errorf("Cannot connect to Marathon server %+v", err) } diff --git a/provider/mesos.go b/provider/mesos.go index 505330218..a9a442096 100644 --- a/provider/mesos.go +++ b/provider/mesos.go @@ -12,6 +12,7 @@ import ( "github.com/cenkalti/backoff" "github.com/containous/traefik/safe" "github.com/containous/traefik/types" + "github.com/containous/traefik/utils" "github.com/mesos/mesos-go/detector" _ "github.com/mesos/mesos-go/detector/zoo" // Registers the ZK detector "github.com/mesosphere/mesos-dns/detect" @@ -110,7 +111,7 @@ func (provider *Mesos) Provide(configurationChan chan<- types.ConfigMessage, poo notify := func(err error, time time.Duration) { log.Errorf("mesos connection error %+v, retrying in %s", err, time) } - err := backoff.RetryNotify(operation, backoff.NewExponentialBackOff(), notify) + err := utils.RetryNotifyJob(operation, backoff.NewExponentialBackOff(), notify) if err != nil { log.Errorf("Cannot connect to mesos server %+v", err) }