From cdd0e4dd57fbb522dc36d9daa983c253e1a1bded Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Thu, 13 Jun 2024 17:08:44 -0400 Subject: [PATCH] should orphan remove finalizer, stop reconciling. Signed-off-by: Troy Connor --- controllers/installation_controller.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/controllers/installation_controller.go b/controllers/installation_controller.go index 94ff4c8a..5ae2a587 100644 --- a/controllers/installation_controller.go +++ b/controllers/installation_controller.go @@ -133,6 +133,10 @@ func (r *InstallationReconciler) Reconcile(ctx context.Context, req ctrl.Request err = r.uninstallInstallation(ctx, log, inst) log.V(Log4Debug).Info("Reconciliation complete: A porter agent has been dispatched to uninstall the installation.") return ctrl.Result{}, err + } else if r.shouldOrphan(inst) { + log.V(Log4Debug).Info("Reconciliation complete: Your installation is being deleted. Please clean up installation resources") + err = removeFinalizer(ctx, log, r.Client, inst) + return ctrl.Result{}, err } else if isDeleted(inst) { // This is installation without a finalizer that was deleted We remove the // finalizer after we successfully uninstall (or someone is manually cleaning @@ -404,6 +408,10 @@ func (r *InstallationReconciler) shouldUninstall(inst *v1.Installation) bool { return isDeleted(inst) && isFinalizerSet(inst) && inst.GetAnnotations()[v1.PorterDeletePolicyAnnotation] == v1.PorterDeletePolicyDelete } +func (r *InstallationReconciler) shouldOrphan(inst *v1.Installation) bool { + return isDeleted(inst) && isFinalizerSet(inst) && inst.GetAnnotations()[v1.PorterDeletePolicyAnnotation] == v1.PorterDeletePolicyOrphan +} + // Sync the retry annotation from the installation to the agent action to trigger another run. func (r *InstallationReconciler) retry(ctx context.Context, log logr.Logger, inst *v1.Installation, action *v1.AgentAction) error { log.V(Log5Trace).Info("Initializing installation status")