Add event for configmap update

This commit is contained in:
Manuel de Brito Fontes 2018-01-18 20:04:40 -03:00
parent 4fe8fc2e41
commit 0287024598
2 changed files with 8 additions and 2 deletions

View file

@ -291,6 +291,10 @@ func (n *NGINXController) Start() {
break break
} }
glog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj) glog.V(3).Infof("Event %v received - object %v", evt.Type, evt.Obj)
if evt.Type == store.ConfigurationEvent {
n.SetForceReload(true)
}
n.syncQueue.Enqueue(evt.Obj) n.syncQueue.Enqueue(evt.Obj)
case <-n.stopCh: case <-n.stopCh:
break break

View file

@ -108,6 +108,8 @@ const (
UpdateEvent EventType = "UPDATE" UpdateEvent EventType = "UPDATE"
// DeleteEvent event associated when an object is removed from an informer // DeleteEvent event associated when an object is removed from an informer
DeleteEvent EventType = "DELETE" DeleteEvent EventType = "DELETE"
// ConfigurationEvent event associated when a configuration object is created or updated
ConfigurationEvent EventType = "CONFIGURATION"
) )
// Event holds the context of an event // Event holds the context of an event
@ -365,7 +367,7 @@ func New(checkOCSP bool,
glog.V(2).Infof("updating configmap backend (%v)", mapKey) glog.V(2).Infof("updating configmap backend (%v)", mapKey)
store.setConfig(m) store.setConfig(m)
updateCh <- Event{ updateCh <- Event{
Type: UpdateEvent, Type: ConfigurationEvent,
Obj: cur, Obj: cur,
} }
} }
@ -373,7 +375,7 @@ func New(checkOCSP bool,
if mapKey == configmap || mapKey == tcp || mapKey == udp { if mapKey == configmap || mapKey == tcp || mapKey == udp {
recorder.Eventf(m, apiv1.EventTypeNormal, "UPDATE", fmt.Sprintf("ConfigMap %v", mapKey)) recorder.Eventf(m, apiv1.EventTypeNormal, "UPDATE", fmt.Sprintf("ConfigMap %v", mapKey))
updateCh <- Event{ updateCh <- Event{
Type: UpdateEvent, Type: ConfigurationEvent,
Obj: cur, Obj: cur,
} }
} }