From bf69be317643cb22d14a48da8fa9d90c062b5750 Mon Sep 17 00:00:00 2001 From: Tsuzu <8574909+tsuzu@users.noreply.github.com> Date: Wed, 1 Jan 2025 00:09:36 +0900 Subject: [PATCH] RequeueAfter --- internal/controller/incusmachine_controller.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/controller/incusmachine_controller.go b/internal/controller/incusmachine_controller.go index 1fadc24..ce54a42 100644 --- a/internal/controller/incusmachine_controller.go +++ b/internal/controller/incusmachine_controller.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "time" "github.com/lxc/incus/shared/api" infrav1alpha1 "github.com/miscord-dev/cluster-api-provider-incus/api/v1alpha1" @@ -224,12 +225,20 @@ func (r *IncusMachineReconciler) reconcileDelete(ctx context.Context, _ *infrav1 if err := r.IncusClient.StopInstance(ctx, incusMachine.Name); err != nil { log.Info("Failed to stop instance", "error", err) } + + return ctrl.Result{ + RequeueAfter: 5 * time.Second, + }, nil } else if output.StatusCode != api.OperationCreated { log.Info("Deleting instance") if err := r.IncusClient.DeleteInstance(ctx, incusMachine.Name); err != nil { return ctrl.Result{}, fmt.Errorf("failed to delete instance: %w", err) } + + return ctrl.Result{ + RequeueAfter: 5 * time.Second, + }, nil } return ctrl.Result{