Skip to content

Commit

Permalink
Merge pull request #4950 from whitewindmills/bindID-webhook
Browse files Browse the repository at this point in the history
cleanup dead code of generating binding permanent id
  • Loading branch information
karmada-bot committed May 21, 2024
2 parents e2b7028 + a9f3c02 commit 1ebaf1d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
5 changes: 0 additions & 5 deletions pkg/controllers/multiclusterservice/mcs_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions pkg/dependenciesdistributor/dependencies_distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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()),
Expand Down
12 changes: 0 additions & 12 deletions pkg/detector/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1ebaf1d

Please sign in to comment.