Skip to content

fix(uninstall): supersede deployed releases#12564

Merged
TerryHowe merged 2 commits intohelm:mainfrom
hiddeco:supersede-on-uninstall
Dec 13, 2025
Merged

fix(uninstall): supersede deployed releases#12564
TerryHowe merged 2 commits intohelm:mainfrom
hiddeco:supersede-on-uninstall

Conversation

@hiddeco
Copy link
Contributor

@hiddeco hiddeco commented Nov 13, 2023

What this PR does / why we need it:

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 was provided.

Fixes #12556


Compared to example commands from above issue:

$ helm install podinfo podinfo/podinfo
NAME: podinfo
LAST DEPLOYED: Mon Nov 13 21:54:51 2023
NAMESPACE: helm-system
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 helm-system 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               Mon Nov 13 21:54:51 2023        superseded      podinfo-6.5.0   6.5.0           Install complete       
2               Mon Nov 13 21:55:21 2023        uninstalled     podinfo-6.5.0   6.5.0           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

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 superseded there.

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

@pull-request-size pull-request-size bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 13, 2023
@hiddeco hiddeco force-pushed the supersede-on-uninstall branch from a69435f to d6065a0 Compare November 13, 2023 21:02
@mattfarina mattfarina added this to the 3.14.0 milestone Nov 14, 2023
@mattfarina mattfarina modified the milestones: 3.14.0, 3.15.0 Mar 13, 2024
Copy link

@MissedTheMark MissedTheMark left a comment

Choose a reason for hiding this comment

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

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

@scottrigby scottrigby added awaiting review bug Categorizes issue or PR as related to a bug. labels May 16, 2024
@scottrigby scottrigby modified the milestones: 3.15.0, 3.15.1 May 16, 2024
@mattfarina mattfarina modified the milestones: 3.15.2, 3.15.3 Jun 12, 2024
@mattfarina mattfarina modified the milestones: 3.15.3, 3.15.4 Jul 10, 2024
@mattfarina mattfarina modified the milestones: 3.15.4, 3.16.0 Aug 14, 2024
@scottrigby scottrigby modified the milestones: 3.16.0, 3.17.0 Sep 11, 2024
@hiddeco
Copy link
Contributor Author

hiddeco commented Sep 12, 2024

Is there anything I can do to help get this included in the v3.17.0 release?

@scottrigby scottrigby modified the milestones: 3.17.0, 3.18.0, 3.17.1 Jan 15, 2025
@mattfarina mattfarina modified the milestones: 3.17.1, 3.17.2 Feb 12, 2025
@hiddeco hiddeco changed the base branch from main to dev-v3 February 13, 2025 06:42
@scottrigby scottrigby modified the milestones: 3.17.2, 3.17.3 Mar 13, 2025
@mattfarina mattfarina modified the milestones: 3.17.3, 3.18.1 May 19, 2025
@scottrigby
Copy link
Member

@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 main and fix there first? Bug fixes can be backported to dev-v3 once fixed in main (if applicable). If it's now a v3 bug only, it's fine to keep this PR. Want to check with you before reviewing as things may change and review may become immediately stale, depending.

Copy link
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

Switch to main branch please!

@hiddeco
Copy link
Contributor Author

hiddeco commented Nov 7, 2025

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

@hiddeco hiddeco changed the base branch from dev-v3 to main November 7, 2025 20:31
@hiddeco hiddeco force-pushed the supersede-on-uninstall branch from d6065a0 to 26bcfeb Compare November 7, 2025 22:06
@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 7, 2025
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>
@hiddeco hiddeco force-pushed the supersede-on-uninstall branch from 26bcfeb to d158708 Compare November 7, 2025 22:10
@hiddeco
Copy link
Contributor Author

hiddeco commented Nov 7, 2025

With the current state of this pull request (after updating it for main and version 4):

$ ./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

Copy link
Member

@scottrigby scottrigby left a comment

Choose a reason for hiding this comment

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

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 scottrigby added Has One Approval This PR has one approval. It still needs a second approval to be merged. and removed awaiting review labels Nov 10, 2025
@scottrigby scottrigby modified the milestones: 3.19.1, 4.0.1 Nov 10, 2025
@hiddeco
Copy link
Contributor Author

hiddeco commented Nov 11, 2025

@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?

Copy link
Contributor

@TerryHowe TerryHowe left a comment

Choose a reason for hiding this comment

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

/lgtm

@scottrigby
Copy link
Member

@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.

@gjenkins8 gjenkins8 modified the milestones: 4.0.1, 4.1.0 Nov 23, 2025
@TerryHowe TerryHowe merged commit 5d2ab10 into helm:main Dec 13, 2025
5 checks passed
@hiddeco hiddeco deleted the supersede-on-uninstall branch December 13, 2025 18:58
@scottrigby scottrigby modified the milestones: 4.1.0, 4.0.5 Jan 12, 2026
@scottrigby scottrigby added needs-pick Indicates that a PR needs to be cherry-picked into the next release candidate. picked Indicates that a PR has been cherry-picked into the next release candidate. and removed Has One Approval This PR has one approval. It still needs a second approval to be merged. needs-pick Indicates that a PR needs to be cherry-picked into the next release candidate. labels Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. picked Indicates that a PR has been cherry-picked into the next release candidate. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm uninstall with --keep-history does not suspend previous deployed releases

6 participants