diff --git a/kubernetes/eventhandler.go b/kubernetes/eventhandler.go index 8dd5d8288..2700742ee 100644 --- a/kubernetes/eventhandler.go +++ b/kubernetes/eventhandler.go @@ -183,8 +183,8 @@ func (n *namespacePodUpdater) OnUpdate(obj interface{}) { cachedNamespace, ok := cachedObject.(*Namespace) if ok && ns.Name == cachedNamespace.Name { - labelscheck := isEqualMetadata(ns.ObjectMeta.Labels, cachedNamespace.ObjectMeta.Labels) - annotationscheck := isEqualMetadata(ns.ObjectMeta.Annotations, cachedNamespace.ObjectMeta.Annotations) + 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() { @@ -244,8 +244,8 @@ func (n *nodePodUpdater) OnUpdate(obj interface{}) { cachedNode, ok := cachedObject.(*Node) if ok && node.Name == cachedNode.Name { - labelscheck := isEqualMetadata(node.ObjectMeta.Labels, cachedNode.ObjectMeta.Labels) - annotationscheck := isEqualMetadata(node.ObjectMeta.Annotations, cachedNode.ObjectMeta.Annotations) + labelscheck := reflect.DeepEqual(node.ObjectMeta.Labels, cachedNode.ObjectMeta.Labels) + annotationscheck := reflect.DeepEqual(node.ObjectMeta.Annotations, cachedNode.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() { @@ -265,9 +265,3 @@ func (*nodePodUpdater) OnAdd(interface{}) {} // OnDelete handles delete events on namespaces. Nothing to do, if pods are deleted from this // namespace they will generate their own delete events. func (*nodePodUpdater) OnDelete(interface{}) {} - -// isEqualMetadata receives labels or annotations maps and checks their equality. Returns True if equal, False if there is a difference -func isEqualMetadata(newmetadata, oldmetadata map[string]string) bool { - check := reflect.DeepEqual(newmetadata, oldmetadata) - return check -}