helm-controller
helm-controller copied to clipboard
Skip uninstall action if SA is not available
To avoid HelmReleases being stuck in finalization when a tenant is deleted, we should skip the uninstall action if the service account is no longer available.
To make helm-controller play nice with multi-tenancy, we could adapt this logic from kustomize-controller:
func (r *KustomizationReconciler) finalize(ctx context.Context, kustomization kustomizev1.Kustomization) (ctrl.Result, error) {
if impersonation.CanFinalize(ctx) {
// purne
} else {
// when the account to impersonate is gone, log the stale objects and continue with the finalization
msg := fmt.Sprintf("unable to prune objects: \n%s", ssa.FmtUnstructuredList(objects))
log.Error(fmt.Errorf("skiping pruning, failed to find account to impersonate"), msg)
}
Ref: https://github.com/fluxcd/kustomize-controller/blob/main/controllers/kustomization_controller.go#L916-L974