Skip to content

fix: stop a failed Helm install/upgrade from silently uninstalling the release - #1912

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:helm-delete
Aug 12, 2026
Merged

fix: stop a failed Helm install/upgrade from silently uninstalling the release#1912
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
gianlucam76:helm-delete

Conversation

@gianlucam76

Copy link
Copy Markdown
Member

shouldInstall decides whether a reconcile enters handleInstall or handleUpgrade. Only the former can ever delete a release when there are a certain number of consecutive failures. shouldInstall tried to infer "is this release already handled" from a version/status comparison, but a failed upgrade still leaves a release record behind, and Helm stamps that record with the version the failed attempt tried to reach, not the version still actually running. So on the reconcile right after a failed upgrade, the release's recorded version already matches what's requested, none of shouldInstall's checks fire, and it falls through to return true. Two failures later (maxHistory defaults to 2), the release gets deleted, then reinstalled from scratch.

shouldInstall:** replace the version/status inference with a direct existence check. A release in any state other than nil or cleanly Uninstalled is now always routed to shouldUpgrade instead.

Decouple the install-retry threshold from maxHistory: the handleInstall trapdoor was reading HelmUpgradeOptions.MaxHistory, a field documented and named for Helm's revision-retention setting. Added HelmInstallOptions.RecoverAfterConsecutiveFailures (default 5) so this knob has its own name and its own doc comment explaining what it does.

…e release

`shouldInstall` decides whether a reconcile enters `handleInstall`
or `handleUpgrade`. Only the former can ever delete a release when there
are a certain number of consecutive failures. `shouldInstall` tried to infer
"is this release already handled" from a version/status comparison, but a *failed*
upgrade still leaves a release record behind, and Helm stamps that record with the
version the failed attempt *tried* to reach, not the version still actually running.
So on the reconcile right after a failed upgrade, the release's recorded version
already matches what's requested, none of `shouldInstall`'s checks fire, and it falls
through to `return true`. Two failures later (`maxHistory` defaults to 2), the release
gets deleted, then reinstalled from scratch.

`shouldInstall`:** replace the version/status inference with a direct
existence check. A release in *any* state other than nil or cleanly
`Uninstalled`  is now always routed to `shouldUpgrade` instead.

Decouple the install-retry threshold from `maxHistory`: the
`handleInstall` trapdoor was reading `HelmUpgradeOptions.MaxHistory`, a field
documented and named for Helm's revision-retention setting.
Added `HelmInstallOptions.RecoverAfterConsecutiveFailures`
(default 5) so this knob has its own name and its own
doc comment explaining what it does.
@gianlucam76
gianlucam76 merged commit df7d04e into projectsveltos:main Aug 12, 2026
11 checks passed
@gianlucam76
gianlucam76 deleted the helm-delete branch August 12, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant