Skip to content

Commit

Permalink
Allow HelmRelease uninstall even if suspended
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Addison <[email protected]>
  • Loading branch information
dippynark committed Nov 25, 2022
1 parent 8d1afa6 commit 5d85f0d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
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

0 comments on commit 5d85f0d

Please sign in to comment.