Skip to content

Commit

Permalink
Merge pull request #5213 from XiShanYongYe-Chang/automated-cherry-pic…
Browse files Browse the repository at this point in the history
…k-of-#5188-upstream-release-1.8

Automated cherry pick of #5188: Fix the issue of residual work in the MultiClusterService
  • Loading branch information
karmada-bot authored Jul 17, 2024
2 parents 4153648 + 0d21a5e commit 2347bf9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ func reportEndpointSlice(c client.Client, endpointSlice *unstructured.Unstructur
util.PropagationInstruction: util.PropagationInstructionSuppressed,
util.ManagedByKarmadaLabel: util.ManagedByKarmadaLabelValue,
},
Finalizers: []string{util.MCSEndpointSliceDispatchControllerFinalizer},
}

if err := helper.CreateOrUpdateWork(c, workMeta, endpointSlice); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,6 @@ func (c *EndpointsliceDispatchController) syncEndpointSlice(ctx context.Context,
return err
}
}

if controllerutil.AddFinalizer(work, util.MCSEndpointSliceDispatchControllerFinalizer) {
if err := c.Client.Update(ctx, work); err != nil {
klog.Errorf("Failed to add finalizer %s for work %s/%s:%v", util.MCSEndpointSliceDispatchControllerFinalizer, work.Namespace, work.Name, err)
return err
}
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/util/helper/work.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func CreateOrUpdateWork(client client.Client, workMeta metav1.ObjectMeta, resour
if util.GetLabelValue(runtimeObject.Labels, workv1alpha2.WorkPermanentIDLabel) == "" {
runtimeObject.Labels = util.DedupeAndMergeLabels(runtimeObject.Labels, map[string]string{workv1alpha2.WorkPermanentIDLabel: uuid.New().String()})
}
runtimeObject.Finalizers = work.Finalizers
return nil
})
if err != nil {
Expand Down

0 comments on commit 2347bf9

Please sign in to comment.