Switch to using wait.ExponentialBackoff
This commit is contained in:
parent
ee6bb942e5
commit
e0020e22d1
1 changed files with 15 additions and 9 deletions
|
@ -30,6 +30,7 @@ import (
|
||||||
extensions "k8s.io/api/extensions/v1beta1"
|
extensions "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/ingress"
|
"k8s.io/ingress-nginx/internal/ingress"
|
||||||
|
@ -185,27 +186,32 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
|
|
||||||
isFirstSync := n.runningConfig.Equal(&ingress.Configuration{})
|
isFirstSync := n.runningConfig.Equal(&ingress.Configuration{})
|
||||||
go func(isFirstSync bool) {
|
go func(isFirstSync bool) {
|
||||||
maxAttempts := 1
|
steps := 1
|
||||||
if isFirstSync {
|
if isFirstSync {
|
||||||
// For the initial sync it always takes some time for NGINX to
|
// For the initial sync it always takes some time for NGINX to
|
||||||
// start listening on the configured port (default 18080)
|
// start listening on the configured port (default 18080)
|
||||||
// For large configurations it might take a while so we loop
|
// For large configurations it might take a while so we loop
|
||||||
// and back off
|
// and back off
|
||||||
maxAttempts = 15
|
steps = 10
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < maxAttempts; i++ {
|
retry := wait.Backoff{
|
||||||
|
Steps: steps,
|
||||||
|
Duration: 1 * time.Second,
|
||||||
|
Factor: 1.5,
|
||||||
|
Jitter: 0.1,
|
||||||
|
}
|
||||||
|
|
||||||
|
wait.ExponentialBackoff(retry, func() (bool, error) {
|
||||||
err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
|
err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
glog.Infof("Dynamic reconfiguration succeeded.")
|
glog.Infof("Dynamic reconfiguration succeeded.")
|
||||||
break
|
return true, nil
|
||||||
} else {
|
|
||||||
glog.Warningf("Dynamic reconfiguration failed: %v", err)
|
|
||||||
// Sleep between retries backing off up to 120s total
|
|
||||||
time.Sleep(time.Duration(i+1) * time.Second)
|
|
||||||
}
|
}
|
||||||
}
|
glog.Warningf("Dynamic reconfiguration failed: %v", err)
|
||||||
|
return false, nil
|
||||||
|
})
|
||||||
}(isFirstSync)
|
}(isFirstSync)
|
||||||
|
|
||||||
ri := getRemovedIngresses(n.runningConfig, pcfg)
|
ri := getRemovedIngresses(n.runningConfig, pcfg)
|
||||||
|
|
Loading…
Reference in a new issue