fix(uninstall): supersede deployed releases#12564
Conversation
a69435f to
d6065a0
Compare
MissedTheMark
left a comment
There was a problem hiding this comment.
These changes look good, and I have verified them locally. It's a shame that the CLI-style tests aren't able to run multiple commands to verify the result properly.
+1 for the clean up of the string literal in rollback.go
TL;DR summary of local testing:
First revision status after install is now superseded as expected.
After then running upgrade with the atomic flag set, it fails with the error UPGRADE FAILED: "podinfo" has no deployed releases, and the number of revisions and their statuses remain as before the failed upgrade attempt, also as expected.
Before this change:
$ helm install podinfo podinfo/podinfo
NAME: podinfo
LAST DEPLOYED: Thu May 9 14:18:43 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl -n default port-forward deploy/podinfo 8080:9898
helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s
Error: UPGRADE FAILED: client rate limiter Wait returned an error: context deadline exceeded
$ helm uninstall podinfo --keep-history
release "podinfo" uninstalled
$ helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu May 9 14:18:43 2024 deployed podinfo-6.6.2 6.6.2 Install complete
2 Thu May 9 14:18:57 2024 uninstalled podinfo-6.6.2 6.6.2 Uninstallation complete
$ helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s --atomic
Error: UPGRADE FAILED: release podinfo failed, and has been rolled back due to atomic being set: client rate limiter Wait returned an error: context deadline exceeded
$ helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu May 9 14:18:43 2024 superseded podinfo-6.6.2 6.6.2 Install complete
2 Thu May 9 14:18:57 2024 uninstalled podinfo-6.6.2 6.6.2 Uninstallation complete
3 Thu May 9 14:20:03 2024 failed podinfo-6.6.2 6.6.2 Upgrade "podinfo" failed: client rate limiter Wait returned an error: context deadline exceeded
4 Thu May 9 14:20:13 2024 deployed podinfo-6.6.2 6.6.2 Rollback to 1 After this change:
$ helm install podinfo podinfo/podinfo
NAME: podinfo
LAST DEPLOYED: Thu May 9 14:20:36 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl -n default port-forward deploy/podinfo 8080:9898
$ helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s
Error: UPGRADE FAILED: context deadline exceeded
$ helm uninstall podinfo --keep-history
release "podinfo" uninstalled
$ helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu May 9 14:20:36 2024 superseded podinfo-6.6.2 6.6.2 Install complete
2 Thu May 9 14:20:49 2024 uninstalled podinfo-6.6.2 6.6.2 Uninstallation complete
$ helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s --atomic
Error: UPGRADE FAILED: "podinfo" has no deployed releases
$ helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Thu May 9 14:20:36 2024 superseded podinfo-6.6.2 6.6.2 Install complete
2 Thu May 9 14:20:49 2024 uninstalled podinfo-6.6.2 6.6.2 Uninstallation complete|
Is there anything I can do to help get this included in the v3.17.0 release? |
|
@hiddeco This looks reasonable to me. But before I add an actual review, is this still a bug in Helm v4? If so, can you change the PR base branch to |
TerryHowe
left a comment
There was a problem hiding this comment.
Switch to main branch please!
|
Can confirm this is still a problem with Helm v4.0.0-rc.1 $ helm install podinfo podinfo/podinfo
level=WARN msg="unable to find exact version; falling back to closest available version" chart=podinfo requested="" selected=6.9.2
NAME: podinfo
LAST DEPLOYED: Fri Nov 7 21:26:00 2025
NAMESPACE: default
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
NOTES:
1. Get the application URL by running these commands:
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl -n default port-forward deploy/podinfo 8080:9898
$ helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s
level=WARN msg="unable to find exact version; falling back to closest available version" chart=podinfo requested="" selected=6.9.2
level=INFO msg="WARN upgrade failed name=podinfo error=\"resource not ready, name: podinfo, kind: Deployment, status: InProgress\\ncontext deadline exceeded\""
Error: UPGRADE FAILED: resource not ready, name: podinfo, kind: Deployment, status: InProgress
context deadline exceeded
$ helm uninstall podinfo --keep-history
release "podinfo" uninstalled
$ helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s --atomic
Flag --atomic has been deprecated, use --rollback-on-failure instead
level=WARN msg="unable to find exact version; falling back to closest available version" chart=podinfo requested="" selected=6.9.2
level=INFO msg="WARN upgrade failed name=podinfo error=\"resource not ready, name: podinfo, kind: Deployment, status: InProgress\\ncontext deadline exceeded\""
Error: UPGRADE FAILED: release podinfo failed, and has been rolled back due to rollback-on-failure being set: resource not ready, name: podinfo, kind: Deployment, status: InProgress
context deadline exceeded
$ helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Nov 7 21:26:00 2025 superseded podinfo-6.9.2 6.9.2 Install complete
2 Fri Nov 7 21:26:08 2025 uninstalled podinfo-6.9.2 6.9.2 Uninstallation complete
3 Fri Nov 7 21:26:44 2025 failed podinfo-6.9.2 6.9.2 Upgrade "podinfo" failed: resource not ready, name: podinfo, kind: Deployment, status: InProgr...
4 Fri Nov 7 21:26:55 2025 deployed podinfo-6.9.2 6.9.2 Rollback to 1 |
d6065a0 to
26bcfeb
Compare
This ensures that when `helm uninstall` is run with `--keep-history` any release in a `deployed` state other than the last release (e.g. due to a failed upgrade) is being marked as `superseded`. As a by-effect, running `helm upgrade` on a release which has been uninstalled after an upgrade failure now no longer works. But instead fails with a `"<name>" has no deployed releases` error. Which is the (likely) intended behavior, and prevents other side-effects like rolling back to a release version which happened before the uninstall if `--atomic` (or `--rollback-on-failure`) was provided. Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
26bcfeb to
d158708
Compare
|
With the current state of this pull request (after updating it for $ ./bin/helm install podinfo podinfo/podinfo
level=WARN msg="unable to find exact version; falling back to closest available version" chart=podinfo requested="" selected=6.9.2
NAME: podinfo
LAST DEPLOYED: Fri Nov 7 23:15:04 2025
NAMESPACE: default
STATUS: deployed
REVISION: 1
DESCRIPTION: Install complete
NOTES:
1. Get the application URL by running these commands:
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl -n default port-forward deploy/podinfo 8080:9898
$ ./bin/helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s
level=WARN msg="unable to find exact version; falling back to closest available version" chart=podinfo requested="" selected=6.9.2
level=INFO msg="WARN upgrade failed name=podinfo error=\"resource not ready, name: podinfo, kind: Deployment, status: InProgress\\ncontext deadline exceeded\""
Error: UPGRADE FAILED: resource not ready, name: podinfo, kind: Deployment, status: InProgress
context deadline exceeded
$ ./bin/helm uninstall podinfo --keep-history
release "podinfo" uninstalled
$ ./bin/helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Nov 7 23:15:04 2025 superseded podinfo-6.9.2 6.9.2 Install complete
2 Fri Nov 7 23:15:05 2025 uninstalled podinfo-6.9.2 6.9.2 Uninstallation complete
$ ./bin/helm upgrade podinfo podinfo/podinfo --set replicaCount=2 --set faults.unready=true --wait --timeout=10s --atomic
Flag --atomic has been deprecated, use --rollback-on-failure instead
level=WARN msg="unable to find exact version; falling back to closest available version" chart=podinfo requested="" selected=6.9.2
Error: UPGRADE FAILED: "podinfo" has no deployed releases
$ ./bin/helm history podinfo
REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION
1 Fri Nov 7 23:15:04 2025 superseded podinfo-6.9.2 6.9.2 Install complete
2 Fri Nov 7 23:15:05 2025 uninstalled podinfo-6.9.2 6.9.2 Uninstallation complete |
scottrigby
left a comment
There was a problem hiding this comment.
Read the previous discussion and agree this makes sense – an uninstall should supersede all previous deployed states if keep-history is enabled. Code and test looks good, and manual testing confirmed the before and after as well. Nice catch 👍
|
@scottrigby I believe the backport of this has to be manual due to rigid changes in v4. Should I prepare this in a separate PR? |
@hiddeco yes please 👍 I don't want to ask you to do extra work, so you can wait until this is merged if you prefer. But yes this is how I would do it. |
What this PR does / why we need it:
This ensures that when
helm uninstallis run with--keep-history, any release in adeployedstate other than the last release (e.g. due to a failed upgrade) is being marked assuperseded.As a by-effect, running
helm upgradeon a release which has been uninstalled after an upgrade failure now no longer works. But instead fails with a"<name>" has no deployed releaseserror. Which is the (likely) intended behavior, and prevents other side-effects like rolling back to a release version which happened before the uninstall if--atomicwas provided.Fixes #12556
Compared to example commands from above issue:
Special notes for your reviewer:
While I added a test from the perspective of the CLI, it appears to be hard to actually validate it being updated to
supersededthere.If applicable: