@@ -35,6 +35,7 @@ import (
3535 "sigs.k8s.io/controller-runtime/pkg/client"
3636
3737 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
38+ clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3839 logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
3940 "sigs.k8s.io/cluster-api/util/conditions"
4041 "sigs.k8s.io/cluster-api/util/patch"
@@ -1064,7 +1065,8 @@ func (o *objectMover) deleteGroup(group moveGroup) error {
10641065}
10651066
10661067var (
1067- removeFinalizersPatch = client .RawPatch (types .MergePatchType , []byte ("{\" metadata\" :{\" finalizers\" :[]}}" ))
1068+ removeFinalizersPatch = client .RawPatch (types .MergePatchType , []byte ("{\" metadata\" :{\" finalizers\" :[]}}" ))
1069+ addDeleteForMoveAnnotationPatch = client .RawPatch (types .JSONPatchType , []byte (fmt .Sprintf ("[{\" op\" : \" add\" , \" path\" :\" /metadata/annotations\" , \" value\" :{%q:\" \" }}]" , clusterctlv1 .DeleteForMoveAnnotation )))
10681070)
10691071
10701072// deleteSourceObject deletes the Kubernetes object corresponding to the node from the source management cluster, taking care of removing all the finalizers so
@@ -1106,6 +1108,11 @@ func (o *objectMover) deleteSourceObject(nodeToDelete *node) error {
11061108 sourceObj .GroupVersionKind (), sourceObj .GetNamespace (), sourceObj .GetName ())
11071109 }
11081110
1111+ if err := cFrom .Patch (ctx , sourceObj , addDeleteForMoveAnnotationPatch ); err != nil {
1112+ return errors .Wrapf (err , "error adding delete-for-move annotation from %q %s/%s" ,
1113+ sourceObj .GroupVersionKind (), sourceObj .GetNamespace (), sourceObj .GetName ())
1114+ }
1115+
11091116 if len (sourceObj .GetFinalizers ()) > 0 {
11101117 if err := cFrom .Patch (ctx , sourceObj , removeFinalizersPatch ); err != nil {
11111118 return errors .Wrapf (err , "error removing finalizers from %q %s/%s" ,
0 commit comments