Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to uninstall a HelmRelease even if it is suspended #568

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v2beta1/helmrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,9 @@ type Uninstall struct {
// a Helm uninstall is performed.
// +optional
DisableWait bool `json:"disableWait,omitempty"`

// IfSuspended uninstalls the release even if it is suspended.
IfSuspended bool `json:"ifSuspended,omitempty"`
}

// GetTimeout returns the configured timeout for the Helm uninstall action, or
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ spec:
description: DisableWait disables waiting for all the resources
to be deleted after a Helm uninstall is performed.
type: boolean
ifSuspended:
description: IfSuspended uninstalls the release even if it is
suspended.
type: boolean
keepHistory:
description: KeepHistory tells Helm to remove all associated resources
and mark the release as deleted, but retain the release history.
Expand Down
5 changes: 3 additions & 2 deletions controllers/helmrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,9 @@ func (r *HelmReleaseReconciler) reconcileDelete(ctx context.Context, hr v2.HelmR
return ctrl.Result{}, err
}

// Only uninstall the Helm Release if the resource is not suspended.
if !hr.Spec.Suspend {
// Only uninstall the Helm Release if the resource is not suspended or if it
// is configured to ignore suspension.
if !hr.Spec.Suspend || hr.Spec.Uninstall.IfSuspended {
getter, err := r.buildRESTClientGetter(ctx, hr)
if err != nil {
return ctrl.Result{}, err
Expand Down
11 changes: 11 additions & 0 deletions docs/api/helmrelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -1877,6 +1877,17 @@ bool
a Helm uninstall is performed.</p>
</td>
</tr>
<tr>
<td>
<code>ifSuspended</code><br>
<em>
bool
</em>
</td>
<td>
<p>IfSuspended uninstalls the release even if it is suspended.</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down