Skip to content

Commit

Permalink
Fix the issue of residual work in the MultiClusterService feature.
Browse files Browse the repository at this point in the history
Signed-off-by: changzhen <[email protected]>
  • Loading branch information
XiShanYongYe-Chang committed Jul 17, 2024
1 parent 4153648 commit 0d21a5e
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 0d21a5e

Please sign in to comment.