Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set background cacscade deletion by default #970

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pkg/util/objectwatcher/objectwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,17 @@ func (o *objectWatcherImpl) Delete(clusterName string, desireObj *unstructured.U
return err
}

err = dynamicClusterClient.DynamicClientSet.Resource(gvr).Namespace(desireObj.GetNamespace()).Delete(context.TODO(), desireObj.GetName(), metav1.DeleteOptions{})
// Set deletion strategy to background explicitly even though it's the default strategy for most of the resources.
// The reason for this is to fix the exception case that Kubernetes does on Job(batch/v1).
// In kubernetes, the Job's default deletion strategy is "Orphan", that will cause the "Pods" created by "Job"
// still exist after "Job" has been deleted.
// Refer to https://github.com/karmada-io/karmada/issues/969 for more details.
deleteBackground := metav1.DeletePropagationBackground
deleteOption := metav1.DeleteOptions{
PropagationPolicy: &deleteBackground,
}

err = dynamicClusterClient.DynamicClientSet.Resource(gvr).Namespace(desireObj.GetNamespace()).Delete(context.TODO(), desireObj.GetName(), deleteOption)
if apierrors.IsNotFound(err) {
err = nil
}
Expand Down