Force reload in template change

This commit is contained in:
Manuel de Brito Fontes 2017-10-08 12:06:37 -03:00
parent 7ffa0ae265
commit 6d43cbfdda
3 changed files with 6 additions and 4 deletions

View file

@ -315,7 +315,7 @@ func (ic *GenericController) syncIngress(item interface{}) error {
setSSLExpireTime(servers) setSSLExpireTime(servers)
ic.runningConfig = &pcfg ic.runningConfig = &pcfg
ic.setForceReload(false) ic.SetForceReload(false)
return nil return nil
} }
@ -1242,9 +1242,10 @@ func (ic *GenericController) isForceReload() bool {
return atomic.LoadInt32(&ic.forceReload) != 0 return atomic.LoadInt32(&ic.forceReload) != 0
} }
func (ic *GenericController) setForceReload(shouldReload bool) { func (ic *GenericController) SetForceReload(shouldReload bool) {
if shouldReload { if shouldReload {
atomic.StoreInt32(&ic.forceReload, 1) atomic.StoreInt32(&ic.forceReload, 1)
ic.syncQueue.Enqueue(&extensions.Ingress{})
} else { } else {
atomic.StoreInt32(&ic.forceReload, 0) atomic.StoreInt32(&ic.forceReload, 0)
} }

View file

@ -172,7 +172,7 @@ func (ic *GenericController) createListers(disableNodeLister bool) (*ingress.Sto
if mapKey == ic.cfg.ConfigMapName { if mapKey == ic.cfg.ConfigMapName {
glog.V(2).Infof("adding configmap %v to backend", mapKey) glog.V(2).Infof("adding configmap %v to backend", mapKey)
ic.cfg.Backend.SetConfig(upCmap) ic.cfg.Backend.SetConfig(upCmap)
ic.setForceReload(true) ic.SetForceReload(true)
} }
}, },
UpdateFunc: func(old, cur interface{}) { UpdateFunc: func(old, cur interface{}) {
@ -182,7 +182,7 @@ func (ic *GenericController) createListers(disableNodeLister bool) (*ingress.Sto
if mapKey == ic.cfg.ConfigMapName { if mapKey == ic.cfg.ConfigMapName {
glog.V(2).Infof("updating configmap backend (%v)", mapKey) glog.V(2).Infof("updating configmap backend (%v)", mapKey)
ic.cfg.Backend.SetConfig(upCmap) ic.cfg.Backend.SetConfig(upCmap)
ic.setForceReload(true) ic.SetForceReload(true)
} }
// updates to configuration configmaps can trigger an update // updates to configuration configmaps can trigger an update
if mapKey == ic.cfg.ConfigMapName || mapKey == ic.cfg.TCPConfigMapName || mapKey == ic.cfg.UDPConfigMapName { if mapKey == ic.cfg.ConfigMapName || mapKey == ic.cfg.TCPConfigMapName || mapKey == ic.cfg.UDPConfigMapName {

View file

@ -106,6 +106,7 @@ Error loading new template : %v
n.t.Close() n.t.Close()
n.t = template n.t = template
glog.Info("new NGINX template loaded") glog.Info("new NGINX template loaded")
n.controller.SetForceReload(true)
} }
ngxTpl, err := ngx_template.NewTemplate(tmplPath, onChange) ngxTpl, err := ngx_template.NewTemplate(tmplPath, onChange)