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

(bug) when cluster is marked as deleted avoid triggering cleanup #710

Merged
merged 1 commit into from
Sep 27, 2024
Merged
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
24 changes: 14 additions & 10 deletions controllers/clustersummary_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func (r *ClusterSummaryReconciler) reconcileDelete(
if err != nil {
return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil
}

if isPresent && isReady { // if cluster is not ready, do not try to clean up. It would fail.
// Cleanup
paused, err := r.isPaused(ctx, clusterSummaryScope.ClusterSummary)
Expand All @@ -251,18 +252,21 @@ func (r *ClusterSummaryReconciler) reconcileDelete(
return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil
}

err = r.undeploy(ctx, clusterSummaryScope, logger)
if err != nil {
// In DryRun mode it is expected to always get an error back
if !clusterSummaryScope.IsDryRunSync() {
logger.V(logs.LogInfo).Error(err, "failed to undeploy")
return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil
if !isDeleted { // if cluster is being deleted do not try to undeploy. Helm client gets stuck and never returns
// if undeploy starts and cluster apiserver is not reachable anymore while helm undeploy is in process
err = r.undeploy(ctx, clusterSummaryScope, logger)
if err != nil {
// In DryRun mode it is expected to always get an error back
if !clusterSummaryScope.IsDryRunSync() {
logger.V(logs.LogInfo).Error(err, "failed to undeploy")
return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil
}
}
}

if !r.canRemoveFinalizer(ctx, clusterSummaryScope, logger) {
logger.V(logs.LogInfo).Error(err, "cannot remove finalizer yet")
return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil
if !r.canRemoveFinalizer(ctx, clusterSummaryScope, logger) {
logger.V(logs.LogInfo).Error(err, "cannot remove finalizer yet")
return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil
}
}
}

Expand Down