Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
entries:
- description: >
For Helm-based operators delete resource, if the Helm uninstall completed with error, then keep trying to uninstall until there is no error on the Helm uninstall.

kind: "change"

breaking: true
Copy link
Copy Markdown
Contributor

@camilamacedo86 camilamacedo86 Mar 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shows that it is more bug fix. Am I right?
@joelanford. Could you please give a hand with this one? Do you think that we should remove the finalizer if Helm uninstallation completed with an error? WDYT?


migration:
header: For Helm-based operators delete resource, the finalizer will not be removed until the Helm uninstall is completed without error.
body: >
In the prior releases, Helm-based operators delete resource will remove it's finalizer even if the Helm uninstallation completed with error.
With this change, Helm-based operators will keep attempting to perform Helm uninstall until it completes without error.
Only then, will the finalizer be removed.
27 changes: 27 additions & 0 deletions internal/helm/release/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,34 @@ func (m manager) UninstallRelease(ctx context.Context, opts ...UninstallOption)
return nil, fmt.Errorf("failed to apply uninstall option: %w", err)
}
}

// Get history of this release
h, err := m.storageBackend.History(m.releaseName)
if err != nil {
return nil, fmt.Errorf("failed to get release history: %w", err)
}
releaseutil.SortByRevision(h)
lastRelease := h[len(h)-1]

// Helm uninstall on a "uninstalled" status doesn't actually perform any resource deletes.
// See: https://github.com/helm/helm/blob/v3.4.2/pkg/action/uninstall.go#L83-L91
// Set the release to "uninstalling" status and trigger the uninstall again.
if lastRelease.Info != nil && lastRelease.Info.Status == rpb.StatusUninstalled {
lastRelease.Info.Status = rpb.StatusUninstalling
if err := m.storageBackend.Update(lastRelease); err != nil {
return nil, err
}
}

// Always keep the release record in case the uninstall errors.
uninstall.KeepHistory = true

uninstallResponse, err := uninstall.Run(m.releaseName)
if err == nil {
// Uninstall was successful so purge the release by running the uninstall again.
uninstall.KeepHistory = false
uninstallResponse, err = uninstall.Run(m.releaseName)
}
if uninstallResponse == nil {
return nil, err
}
Expand Down