Skip to content

Commit c057d3f

Browse files
🐛 Fix deletion patch error (#167)
**What is the purpose of this pull request/Why do we need it?** Cherry pick of #163 for release 0.2.1 Co-authored-by: lubedacht <[email protected]>
1 parent 2eff85e commit c057d3f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/controller/ionoscloudmachine_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (r *IonosCloudMachineReconciler) reconcileDelete(
215215

216216
if requeue {
217217
log.Info("Deletion request is still in progress")
218-
return ctrl.Result{RequeueAfter: defaultReconcileDuration}, nil
218+
return ctrl.Result{RequeueAfter: reducedReconcileDuration}, nil
219219
}
220220

221221
reconcileSequence := []serviceReconcileStep[scope.Machine]{
@@ -237,7 +237,6 @@ func (r *IonosCloudMachineReconciler) reconcileDelete(
237237
return ctrl.Result{RequeueAfter: defaultReconcileDuration}, err
238238
}
239239
}
240-
241240
controllerutil.RemoveFinalizer(machineScope.IonosMachine, infrav1.MachineFinalizer)
242241
return ctrl.Result{}, nil
243242
}
@@ -286,6 +285,12 @@ func (*IonosCloudMachineReconciler) checkRequestStates(
286285
return nil
287286
},
288287
)
288+
289+
// We need to patch the machine during the deletion phase to make sure we do
290+
// not have a diff in the status during the final patch when the finalizer is removed.
291+
if !machineScope.IonosMachine.DeletionTimestamp.IsZero() {
292+
requeue, retErr = true, machineScope.PatchObject()
293+
}
289294
}
290295
}
291296

internal/controller/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636

3737
const (
3838
defaultReconcileDuration = time.Second * 20
39+
reducedReconcileDuration = time.Second * 10
3940
)
4041

4142
type serviceReconcileStep[T scope.Cluster | scope.Machine] struct {

0 commit comments

Comments
 (0)