From 7d6c0f7c47dfce53b708c00577117c4ad410ed77 Mon Sep 17 00:00:00 2001
From: Samuel Torres
Date: Tue, 15 Feb 2022 18:07:59 +0000
Subject: [PATCH] Add disableWait property on Helm uninstall
This commit changes the default behavior of the Helm uninstall action
to wait for all resources to be deleted, and introduces a
`.spec.uninstall.disableWait` flag to disable this behavior.
Signed-off-by: Samuel Torres
---
api/v2beta1/helmrelease_types.go | 5 +++++
.../bases/helm.toolkit.fluxcd.io_helmreleases.yaml | 4 ++++
docs/api/helmrelease.md | 13 +++++++++++++
internal/runner/runner.go | 1 +
4 files changed, 23 insertions(+)
diff --git a/api/v2beta1/helmrelease_types.go b/api/v2beta1/helmrelease_types.go
index 6fa683d..3b024d2 100644
--- a/api/v2beta1/helmrelease_types.go
+++ b/api/v2beta1/helmrelease_types.go
@@ -754,6 +754,11 @@ type Uninstall struct {
// release as deleted, but retain the release history.
// +optional
KeepHistory bool `json:"keepHistory,omitempty"`
+
+ // DisableWait disables waiting for all the resources to be deleted after
+ // a Helm uninstall is performed.
+ // +optional
+ DisableWait bool `json:"disableWait,omitempty"`
}
// GetTimeout returns the configured timeout for the Helm uninstall action, or
diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
index 163abc8..a06e74a 100644
--- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
+++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
@@ -497,6 +497,10 @@ spec:
description: DisableHooks prevents hooks from running during the
Helm rollback action.
type: boolean
+ disableWait:
+ description: DisableWait disables waiting for all the resources
+ to be deleted after a Helm uninstall is performed.
+ type: boolean
keepHistory:
description: KeepHistory tells Helm to remove all associated resources
and mark the release as deleted, but retain the release history.
diff --git a/docs/api/helmrelease.md b/docs/api/helmrelease.md
index 1219421..f4ee502 100644
--- a/docs/api/helmrelease.md
+++ b/docs/api/helmrelease.md
@@ -1755,6 +1755,19 @@ bool
release as deleted, but retain the release history.
+
+
+disableWait
+
+bool
+
+ |
+
+(Optional)
+ DisableWait disables waiting for all the resources to be deleted after
+a Helm uninstall is performed.
+ |
+
diff --git a/internal/runner/runner.go b/internal/runner/runner.go
index 9ffd92c..0b84875 100644
--- a/internal/runner/runner.go
+++ b/internal/runner/runner.go
@@ -375,6 +375,7 @@ func (r *Runner) Uninstall(hr v2.HelmRelease) error {
uninstall.Timeout = hr.Spec.GetUninstall().GetTimeout(hr.GetTimeout()).Duration
uninstall.DisableHooks = hr.Spec.GetUninstall().DisableHooks
uninstall.KeepHistory = hr.Spec.GetUninstall().KeepHistory
+ uninstall.Wait = !hr.Spec.GetUninstall().DisableWait
_, err := uninstall.Run(hr.GetReleaseName())
return wrapActionErr(r.logBuffer, err)