From abb9df1570e45f0cb8ba25a7864386e54f21c578 Mon Sep 17 00:00:00 2001 From: Junguk Cho Date: Mon, 15 Nov 2021 16:16:32 -0800 Subject: [PATCH] Use Equal function for label instead of using reflect.DeepEqual in namespaceController --- npm/pkg/controlplane/controllers/v1/nameSpaceController.go | 4 ++-- npm/pkg/controlplane/controllers/v2/namespacecontroller.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/npm/pkg/controlplane/controllers/v1/nameSpaceController.go b/npm/pkg/controlplane/controllers/v1/nameSpaceController.go index 78ae77ed70..80a32fd0eb 100644 --- a/npm/pkg/controlplane/controllers/v1/nameSpaceController.go +++ b/npm/pkg/controlplane/controllers/v1/nameSpaceController.go @@ -5,7 +5,6 @@ package controllers import ( "encoding/json" "fmt" - "reflect" "sync" "time" @@ -15,6 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8slabels "k8s.io/apimachinery/pkg/labels" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" coreinformer "k8s.io/client-go/informers/core/v1" @@ -288,7 +288,7 @@ func (nsc *NamespaceController) syncNameSpace(key string) error { cachedNsObj, nsExists := nsc.npmNamespaceCache.NsMap[cachedNsKey] if nsExists { - if reflect.DeepEqual(cachedNsObj.LabelsMap, nsObj.ObjectMeta.Labels) { + if k8slabels.Equals(cachedNsObj.LabelsMap, nsObj.ObjectMeta.Labels) { klog.Infof("[NAMESPACE UPDATE EVENT] Namespace [%s] labels did not change", key) return nil } diff --git a/npm/pkg/controlplane/controllers/v2/namespacecontroller.go b/npm/pkg/controlplane/controllers/v2/namespacecontroller.go index 76917e8d1f..7c2051386e 100644 --- a/npm/pkg/controlplane/controllers/v2/namespacecontroller.go +++ b/npm/pkg/controlplane/controllers/v2/namespacecontroller.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - "reflect" "sync" "time" @@ -16,6 +15,7 @@ import ( "github.com/Azure/azure-container-networking/npm/util" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" + k8slabels "k8s.io/apimachinery/pkg/labels" utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" coreinformer "k8s.io/client-go/informers/core/v1" @@ -285,7 +285,7 @@ func (nsc *NamespaceController) syncNamespace(nsKey string) error { cachedNsObj, nsExists := nsc.npmNamespaceCache.NsMap[nsKey] if nsExists { - if reflect.DeepEqual(cachedNsObj.LabelsMap, nsObj.ObjectMeta.Labels) { + if k8slabels.Equals(cachedNsObj.LabelsMap, nsObj.ObjectMeta.Labels) { klog.Infof("[NAMESPACE UPDATE EVENT] Namespace [%s] labels did not change", nsKey) return nil }