Retry initial backend configuration

This commit is contained in:
Corey O'Brien 2018-10-11 23:47:50 -04:00
parent 469797e242
commit ee6bb942e5

View file

@ -185,17 +185,26 @@ 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
if isFirstSync { if isFirstSync {
glog.Infof("Initial synchronization of the NGINX configuration.") // For the initial sync it always takes some time for NGINX to
// start listening on the configured port (default 18080)
// it takes time for NGINX to start listening on the configured ports // For large configurations it might take a while so we loop
// and back off
maxAttempts = 15
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
} }
err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
if err == nil { for i := 0; i < maxAttempts; i++ {
glog.Infof("Dynamic reconfiguration succeeded.") err := configureDynamically(pcfg, n.cfg.ListenPorts.Status, n.cfg.DynamicCertificatesEnabled)
} else { if err == nil {
glog.Warningf("Dynamic reconfiguration failed: %v", err) glog.Infof("Dynamic reconfiguration succeeded.")
break
} 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)
}
} }
}(isFirstSync) }(isFirstSync)