Skip to content

Commit

Permalink
Properly handle ongoing upgrades
Browse files Browse the repository at this point in the history
Signed-off-by: Atanas Dinov <[email protected]>
  • Loading branch information
atanasdinov committed Aug 29, 2024
1 parent 0254ae4 commit 4768159
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/controller/upgradeplan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

var errUpgradeInProgress = errors.New("upgrade is currently in progress")

// UpgradePlanReconciler reconciles a UpgradePlan object
type UpgradePlanReconciler struct {
client.Client
Expand Down Expand Up @@ -87,6 +89,11 @@ func (r *UpgradePlanReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}

if err := r.reconcileDelete(ctx, plan); err != nil {
if errors.Is(err, errUpgradeInProgress) {
// Requeue here is not necessary since the plan
// will be reconciled again once the upgrade is complete.
return ctrl.Result{}, nil
}
return ctrl.Result{}, err
}

Expand Down Expand Up @@ -121,8 +128,7 @@ func (r *UpgradePlanReconciler) reconcileDelete(ctx context.Context, upgradePlan
}

if len(plan.Status.Applying) != 0 {
// Wait for the upgrade to be completed.
return nil
return errUpgradeInProgress
}

if err := r.Delete(ctx, &plan); err != nil {
Expand Down

0 comments on commit 4768159

Please sign in to comment.