do not rely on force reload to dynamically configure when reload is needed
This commit is contained in:
parent
0338f63301
commit
3f27e51bb3
4 changed files with 17 additions and 24 deletions
|
@ -169,15 +169,21 @@ func (n *NGINXController) syncIngress(item interface{}) error {
|
|||
if !n.isForceReload() && n.runningConfig.Equal(&pcfg) {
|
||||
glog.V(3).Infof("skipping backend reload (no changes detected)")
|
||||
return nil
|
||||
} else if !n.isForceReload() && n.cfg.DynamicConfigurationEnabled && n.IsDynamicallyConfigurable(&pcfg) {
|
||||
}
|
||||
|
||||
if n.cfg.DynamicConfigurationEnabled {
|
||||
err := n.ConfigureDynamically(&pcfg)
|
||||
if err == nil {
|
||||
glog.Infof("dynamic reconfiguration succeeded, skipping reload")
|
||||
n.runningConfig = &pcfg
|
||||
return nil
|
||||
}
|
||||
glog.Infof("dynamic reconfiguration succeeded")
|
||||
|
||||
glog.Warningf("falling back to reload, could not dynamically reconfigure: %v", err)
|
||||
if !n.isForceReload() && n.IsDynamicConfiguratonEnough(&pcfg) {
|
||||
glog.Infof("skipping reload")
|
||||
n.runningConfig = &pcfg
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
glog.Warningf("could not dynamically reconfigure: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
glog.Infof("backend reload required")
|
||||
|
@ -193,19 +199,6 @@ func (n *NGINXController) syncIngress(item interface{}) error {
|
|||
incReloadCount()
|
||||
setSSLExpireTime(servers)
|
||||
|
||||
if n.isForceReload() && n.cfg.DynamicConfigurationEnabled {
|
||||
go func() {
|
||||
// it takes time for Nginx to start listening on the port
|
||||
time.Sleep(1 * time.Second)
|
||||
err := n.ConfigureDynamically(&pcfg)
|
||||
if err == nil {
|
||||
glog.Infof("dynamic reconfiguration succeeded")
|
||||
} else {
|
||||
glog.Warningf("could not dynamically reconfigure: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
n.runningConfig = &pcfg
|
||||
n.SetForceReload(false)
|
||||
|
||||
|
|
|
@ -751,8 +751,8 @@ func (n *NGINXController) setupSSLProxy() {
|
|||
}()
|
||||
}
|
||||
|
||||
// IsDynamicallyConfigurable decides if the new configuration can be dynamically configured without reloading
|
||||
func (n *NGINXController) IsDynamicallyConfigurable(pcfg *ingress.Configuration) bool {
|
||||
// IsDynamicConfiguratonEnough decides if the new configuration changes can be dynamically applied without reloading
|
||||
func (n *NGINXController) IsDynamicConfiguratonEnough(pcfg *ingress.Configuration) bool {
|
||||
var copyOfRunningConfig ingress.Configuration = *n.runningConfig
|
||||
var copyOfPcfg ingress.Configuration = *pcfg
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress"
|
||||
)
|
||||
|
||||
func TestIsDynamicallyConfigurable(t *testing.T) {
|
||||
func IsDynamicConfiguratonEnough(t *testing.T) {
|
||||
backends := []*ingress.Backend{{
|
||||
Name: "fakenamespace-myapp-80",
|
||||
Endpoints: []ingress.Endpoint{
|
||||
|
|
|
@ -117,7 +117,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() {
|
|||
Expect(log).ToNot(BeEmpty())
|
||||
|
||||
By("skipping Nginx reload")
|
||||
Expect(log).To(ContainSubstring("skipping reload since only backends changed"))
|
||||
Expect(log).To(ContainSubstring("skipping reload"))
|
||||
|
||||
By("POSTing new backends to Lua endpoint")
|
||||
Expect(log).To(ContainSubstring("dynamic reconfiguration succeeded"))
|
||||
|
@ -138,7 +138,7 @@ var _ = framework.IngressNginxDescribe("Dynamic Configuration", func() {
|
|||
Expect(log).ToNot(BeEmpty())
|
||||
|
||||
By("skipping Nginx reload")
|
||||
Expect(log).To(ContainSubstring("skipping reload since only backends changed"))
|
||||
Expect(log).To(ContainSubstring("skipping reload"))
|
||||
|
||||
By("POSTing new backends to Lua endpoint")
|
||||
Expect(log).To(ContainSubstring("dynamic reconfiguration succeeded"))
|
||||
|
|
Loading…
Reference in a new issue