Skip to content

Commit

Permalink
RequeueAfter
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuzu committed Dec 31, 2024
1 parent ccadc57 commit bf69be3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/controller/incusmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit bf69be3

Please sign in to comment.