From 2d2af96966ca8103fddf1d8acb7296a84b2e7df0 Mon Sep 17 00:00:00 2001 From: janiskemper Date: Tue, 20 Feb 2024 13:23:27 +0100 Subject: [PATCH] :bug: Fix delete of csr if assets cannot be downloaded Fix delete of ClusterStackRelease object in case that there is a problem with the release assets. Currently, the reconcileDelete function requires assets to be downloaded properly. If this is not the case, then the object does not get deleted and is stuck forever. This happens for example when a user specifies a version of a clusterstack that does not exist. Then a ClusterStackRelease object is created, but will never get deleted again, because the downloading of the release assets fails, as the release does not exist. Now we have an additional check to remove the finalizer without any further logic in case there is an issue with the release assets. Signed-off-by: janiskemper --- internal/controller/clusterstackrelease_controller.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/controller/clusterstackrelease_controller.go b/internal/controller/clusterstackrelease_controller.go index b5a977045..4ec16eb74 100644 --- a/internal/controller/clusterstackrelease_controller.go +++ b/internal/controller/clusterstackrelease_controller.go @@ -89,6 +89,13 @@ func (r *ClusterStackReleaseReconciler) Reconcile(ctx context.Context, req recon defer func() { conditions.SetSummary(clusterStackRelease) + // Check if the object has a deletion timestamp and release assets have not been downloaded properly. + // In that case, the controller cannot perform a proper reconcileDelete and we just remove the finalizer. + if !clusterStackRelease.DeletionTimestamp.IsZero() && + conditions.IsFalse(clusterStackRelease, csov1alpha1.ClusterStackReleaseAssetsReadyCondition) { + controllerutil.RemoveFinalizer(clusterStackRelease, csov1alpha1.ClusterStackReleaseFinalizer) + } + if err := patchHelper.Patch(ctx, clusterStackRelease); err != nil { reterr = fmt.Errorf("failed to patch ClusterStackRelease: %w", err) }