Merge pull request #5052 from janosi/cm-add-event

Change the handling of ConfigMap creation
This commit is contained in:
Kubernetes Prow Robot 2020-02-11 03:34:03 -08:00 committed by GitHub
commit fc41dc732a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -535,19 +535,40 @@ func New(
AddFunc: func(obj interface{}) { AddFunc: func(obj interface{}) {
cm := obj.(*corev1.ConfigMap) cm := obj.(*corev1.ConfigMap)
key := k8s.MetaNamespaceKey(cm) key := k8s.MetaNamespaceKey(cm)
triggerUpdate := false
// updates to configuration configmaps can trigger an update // updates to configuration configmaps can trigger an update
if changeTriggerUpdate(key) { if changeTriggerUpdate(key) {
recorder.Eventf(cm, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("ConfigMap %v", key)) recorder.Eventf(cm, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("ConfigMap %v", key))
triggerUpdate = true
if key == configmap { if key == configmap {
store.setConfig(cm) store.setConfig(cm)
} }
} }
ings := store.listers.IngressWithAnnotation.List()
for _, ingKey := range ings {
key := k8s.MetaNamespaceKey(ingKey)
ing, err := store.getIngress(key)
if err != nil {
klog.Errorf("could not find Ingress %v in local store: %v", key, err)
continue
}
if parser.AnnotationsReferencesConfigmap(ing) {
recorder.Eventf(cm, corev1.EventTypeNormal, "CREATE", fmt.Sprintf("ConfigMap %v", key))
store.syncIngress(ing)
triggerUpdate = true
}
}
if triggerUpdate {
updateCh.In() <- Event{ updateCh.In() <- Event{
Type: ConfigurationEvent, Type: ConfigurationEvent,
Obj: obj, Obj: obj,
} }
}
}, },
UpdateFunc: func(old, cur interface{}) { UpdateFunc: func(old, cur interface{}) {
if reflect.DeepEqual(old, cur) { if reflect.DeepEqual(old, cur) {