From f573777eb40b183b22a16453adc581c4c350878a Mon Sep 17 00:00:00 2001 From: whitewindmills Date: Tue, 2 Apr 2024 19:08:12 +0800 Subject: [PATCH] Use merge strategy to avoid work.karmada.io/permanent-id changes. Signed-off-by: whitewindmills --- pkg/util/helper/work.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/util/helper/work.go b/pkg/util/helper/work.go index ed83e7db1714..9af79a4ceaf8 100644 --- a/pkg/util/helper/work.go +++ b/pkg/util/helper/work.go @@ -80,8 +80,8 @@ func CreateOrUpdateWork(client client.Client, workMeta metav1.ObjectMeta, resour // TODO: Delete following one line in release-1.9 delete(runtimeObject.Labels, workv1alpha2.WorkUIDLabel) runtimeObject.Spec = work.Spec - runtimeObject.Labels = work.Labels - runtimeObject.Annotations = work.Annotations + 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()}) }