Skip to content

Commit

Permalink
🐛 Fix deletion patch error (#163)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas Riedel <138458199+jriedel-ionos@users.noreply.github.com>
  • Loading branch information
lubedacht and jriedel-ionos committed Jun 26, 2024
1 parent 7c1f1a6 commit 0457601
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/controller/ionoscloudmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (r *IonosCloudMachineReconciler) reconcileDelete(

if requeue {
log.Info("Deletion request is still in progress")
return ctrl.Result{RequeueAfter: defaultReconcileDuration}, nil
return ctrl.Result{RequeueAfter: reducedReconcileDuration}, nil
}

reconcileSequence := []serviceReconcileStep[scope.Machine]{
Expand All @@ -237,7 +237,6 @@ func (r *IonosCloudMachineReconciler) reconcileDelete(
return ctrl.Result{RequeueAfter: defaultReconcileDuration}, err
}
}

controllerutil.RemoveFinalizer(machineScope.IonosMachine, infrav1.MachineFinalizer)
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -286,6 +285,12 @@ func (*IonosCloudMachineReconciler) checkRequestStates(
return nil
},
)

// We need to patch the machine during the deletion phase to make sure we do
// not have a diff in the status during the final patch when the finalizer is removed.
if !machineScope.IonosMachine.DeletionTimestamp.IsZero() {
requeue, retErr = true, machineScope.PatchObject()
}
}
}

Expand Down
1 change: 1 addition & 0 deletions internal/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (

const (
defaultReconcileDuration = time.Second * 20
reducedReconcileDuration = time.Second * 10
)

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

0 comments on commit 0457601

Please sign in to comment.