@@ -35,6 +35,7 @@ import (
35
35
"sigs.k8s.io/controller-runtime/pkg/client"
36
36
37
37
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
38
+ clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
38
39
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
39
40
"sigs.k8s.io/cluster-api/util/conditions"
40
41
"sigs.k8s.io/cluster-api/util/patch"
@@ -1064,7 +1065,8 @@ func (o *objectMover) deleteGroup(group moveGroup) error {
1064
1065
}
1065
1066
1066
1067
var (
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 )))
1068
1070
)
1069
1071
1070
1072
// 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 {
1106
1108
sourceObj .GroupVersionKind (), sourceObj .GetNamespace (), sourceObj .GetName ())
1107
1109
}
1108
1110
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
+
1109
1116
if len (sourceObj .GetFinalizers ()) > 0 {
1110
1117
if err := cFrom .Patch (ctx , sourceObj , removeFinalizersPatch ); err != nil {
1111
1118
return errors .Wrapf (err , "error removing finalizers from %q %s/%s" ,
0 commit comments