From a9f3c0294840511cb10cbc471d5688d9e4159371 Mon Sep 17 00:00:00 2001 From: whitewindmills Date: Thu, 16 May 2024 14:58:31 +0800 Subject: [PATCH] clean up dead code of generating binding permanent id Signed-off-by: whitewindmills --- .../multiclusterservice/mcs_controller.go | 5 ----- .../dependencies_distributor.go | 7 ++----- pkg/detector/detector.go | 12 ------------ 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/pkg/controllers/multiclusterservice/mcs_controller.go b/pkg/controllers/multiclusterservice/mcs_controller.go index 6ba68843e393..3e353261b0db 100644 --- a/pkg/controllers/multiclusterservice/mcs_controller.go +++ b/pkg/controllers/multiclusterservice/mcs_controller.go @@ -20,7 +20,6 @@ import ( "context" "fmt" - "github.com/google/uuid" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -407,10 +406,6 @@ func (c *MCSController) propagateService(ctx context.Context, mcs *networkingv1a "try again later after binding is garbage collected, see https://github.com/karmada-io/karmada/issues/2090") } - if util.GetLabelValue(bindingCopy.Labels, workv1alpha2.ResourceBindingPermanentIDLabel) == "" { - bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, - map[string]string{workv1alpha2.ResourceBindingPermanentIDLabel: uuid.New().String()}) - } // Just update necessary fields, especially avoid modifying Spec.Clusters which is scheduling result, if already exists. bindingCopy.Annotations = util.DedupeAndMergeAnnotations(bindingCopy.Annotations, binding.Annotations) bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, binding.Labels) diff --git a/pkg/dependenciesdistributor/dependencies_distributor.go b/pkg/dependenciesdistributor/dependencies_distributor.go index 4e05f37ace5a..f3d870ef9c92 100644 --- a/pkg/dependenciesdistributor/dependencies_distributor.go +++ b/pkg/dependenciesdistributor/dependencies_distributor.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" - "github.com/google/uuid" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" @@ -538,8 +537,6 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding return err } - attachedBinding.Labels = util.DedupeAndMergeLabels(attachedBinding.Labels, - map[string]string{workv1alpha2.ResourceBindingPermanentIDLabel: uuid.New().String()}) if err := d.Client.Create(context.TODO(), attachedBinding); err != nil { return err } @@ -653,8 +650,8 @@ func buildAttachedBinding(binding *workv1alpha2.ResourceBinding, object *unstruc Clusters: binding.Spec.Clusters, }) - policyID := util.GetLabelValue(binding.Labels, workv1alpha2.ResourceBindingPermanentIDLabel) - dependedLabels = util.DedupeAndMergeLabels(dependedLabels, map[string]string{bindingDependedIDLabelKey: policyID}) + bindingID := util.GetLabelValue(binding.Labels, workv1alpha2.ResourceBindingPermanentIDLabel) + dependedLabels = util.DedupeAndMergeLabels(dependedLabels, map[string]string{bindingDependedIDLabelKey: bindingID}) return &workv1alpha2.ResourceBinding{ ObjectMeta: metav1.ObjectMeta{ Name: names.GenerateBindingName(object.GetKind(), object.GetName()), diff --git a/pkg/detector/detector.go b/pkg/detector/detector.go index 54fdb680f73c..16d263d8c251 100644 --- a/pkg/detector/detector.go +++ b/pkg/detector/detector.go @@ -496,10 +496,6 @@ func (d *ResourceDetector) ApplyPolicy(object *unstructured.Unstructured, object "try again later after binding is garbage collected, see https://github.com/karmada-io/karmada/issues/2090") } - if util.GetLabelValue(bindingCopy.Labels, workv1alpha2.ResourceBindingPermanentIDLabel) == "" { - bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, - map[string]string{workv1alpha2.ResourceBindingPermanentIDLabel: uuid.New().String()}) - } // Just update necessary fields, especially avoid modifying Spec.Clusters which is scheduling result, if already exists. bindingCopy.Annotations = util.DedupeAndMergeAnnotations(bindingCopy.Annotations, binding.Annotations) bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, binding.Labels) @@ -596,10 +592,6 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured, "try again later after binding is garbage collected, see https://github.com/karmada-io/karmada/issues/2090") } - if util.GetLabelValue(bindingCopy.Labels, workv1alpha2.ResourceBindingPermanentIDLabel) == "" { - bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, - map[string]string{workv1alpha2.ResourceBindingPermanentIDLabel: uuid.New().String()}) - } // Just update necessary fields, especially avoid modifying Spec.Clusters which is scheduling result, if already exists. bindingCopy.Annotations = util.DedupeAndMergeAnnotations(bindingCopy.Annotations, binding.Annotations) bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, binding.Labels) @@ -646,10 +638,6 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured, "try again later after binding is garbage collected, see https://github.com/karmada-io/karmada/issues/2090") } - if util.GetLabelValue(bindingCopy.Labels, workv1alpha2.ClusterResourceBindingPermanentIDLabel) == "" { - bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, - map[string]string{workv1alpha2.ClusterResourceBindingPermanentIDLabel: uuid.New().String()}) - } // Just update necessary fields, especially avoid modifying Spec.Clusters which is scheduling result, if already exists. bindingCopy.Annotations = util.DedupeAndMergeAnnotations(bindingCopy.Annotations, binding.Annotations) bindingCopy.Labels = util.DedupeAndMergeLabels(bindingCopy.Labels, binding.Labels)