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

🐛 Fix deletion patch error #163

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
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
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
Loading