func()

in kubernetes/eventhandler.go [158:190]


func (n *namespacePodUpdater) OnUpdate(obj interface{}) {
	ns, ok := obj.(*Namespace)
	if !ok {
		return
	}
	// n.store.List() returns a snapshot at this point. If a delete is received
	// from the main watcher, this loop may generate an update event after the
	// delete is processed, leaving configurations that would never be deleted.
	// Also this loop can miss updates, what could leave outdated configurations.
	// Avoid these issues by locking the processing of events from the main watcher.
	if n.locker != nil {
		n.locker.Lock()
		defer n.locker.Unlock()
	}

	cachedObject := n.namespaceWatcher.CachedObject()
	cachedNamespace, ok := cachedObject.(*Namespace)

	if ok && ns.Name == cachedNamespace.Name {
		labelscheck := reflect.DeepEqual(ns.ObjectMeta.Labels, cachedNamespace.ObjectMeta.Labels)
		annotationscheck := reflect.DeepEqual(ns.ObjectMeta.Annotations, cachedNamespace.ObjectMeta.Annotations)
		// Only if there is a difference in Metadata labels or annotations proceed to Pod update
		if !labelscheck || !annotationscheck {
			for _, pod := range n.store.List() {
				pod, ok := pod.(*Pod)
				if ok && pod.Namespace == ns.Name {
					n.handler(pod)
				}
			}
		}
	}

}