fix: stop a failed Helm install/upgrade from silently uninstalling the release - #1912
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
shouldInstalldecides whether a reconcile entershandleInstallorhandleUpgrade. Only the former can ever delete a release when there are a certain number of consecutive failures.shouldInstalltried 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 ofshouldInstall's checks fire, and it falls through toreturn true. Two failures later (maxHistorydefaults 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 cleanlyUninstalledis now always routed toshouldUpgradeinstead.Decouple the install-retry threshold from
maxHistory: thehandleInstalltrapdoor was readingHelmUpgradeOptions.MaxHistory, a field documented and named for Helm's revision-retention setting. AddedHelmInstallOptions.RecoverAfterConsecutiveFailures(default 5) so this knob has its own name and its own doc comment explaining what it does.