Skip to content

Commit

Permalink
Merge pull request #4928 from whitewindmills/work-id-generation
Browse files Browse the repository at this point in the history
cleanup dead code of generating Work permanent id
  • Loading branch information
karmada-bot committed May 13, 2024
2 parents 124c396 + 93a04cb commit 63e6fcf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions pkg/util/helper/work.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"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -72,9 +71,6 @@ func CreateOrUpdateWork(client client.Client, workMeta metav1.ObjectMeta, resour
runtimeObject.Spec = work.Spec
runtimeObject.Labels = util.DedupeAndMergeLabels(runtimeObject.Labels, work.Labels)
runtimeObject.Annotations = util.DedupeAndMergeAnnotations(runtimeObject.Annotations, work.Annotations)
if util.GetLabelValue(runtimeObject.Labels, workv1alpha2.WorkPermanentIDLabel) == "" {
runtimeObject.Labels = util.DedupeAndMergeLabels(runtimeObject.Labels, map[string]string{workv1alpha2.WorkPermanentIDLabel: uuid.New().String()})
}
return nil
})
return err
Expand Down
8 changes: 4 additions & 4 deletions pkg/webhook/work/mutating.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
}
klog.V(2).Infof("Mutating the work(%s/%s) for request: %s", work.Namespace, work.Name, req.Operation)

if util.GetLabelValue(work.Labels, workv1alpha2.WorkPermanentIDLabel) == "" {
util.MergeLabel(work, workv1alpha2.WorkPermanentIDLabel, uuid.New().String())
}

var manifests []workv1alpha1.Manifest

for _, manifest := range work.Spec.Workload.Manifests {
Expand Down Expand Up @@ -86,10 +90,6 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
return admission.Errored(http.StatusInternalServerError, err)
}

if util.GetLabelValue(work.Labels, workv1alpha2.WorkPermanentIDLabel) == "" {
util.MergeLabel(work, workv1alpha2.WorkPermanentIDLabel, uuid.New().String())
}

return admission.PatchResponseFromRaw(req.Object.Raw, marshaledBytes)
}

Expand Down

0 comments on commit 63e6fcf

Please sign in to comment.