Skip to content

Commit

Permalink
should orphan remove finalizer, stop reconciling.
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Connor <[email protected]>
  • Loading branch information
troy0820 committed Jun 13, 2024
1 parent f86040f commit cdd0e4d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions controllers/installation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit cdd0e4d

Please sign in to comment.