You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation request about --cleanup-on-fail, --atomic, --force #7811
I'd love to gain clarity on the flags --cleanup-on-fail, --atomic, and --force in helm3 upgrade. What is it that they do if used by themselves, and will this change if they are used together with another flag?
--atomic if set, upgrade process rolls back changes made in case of failed upgrade. The --wait flag will be set automatically if --atomic is used
--cleanup-on-fail allow deletion of new resources created in this upgrade when upgrade fails
--force force resource updates through a replacement strategy
Questions
Will --force use a replacement strategy for all resources no matter what?
Will --atomic imply --cleanup-on-fail?
In --cleanup-on-fail, what does it mean to allow deletion of new resources on failure? Will these resources be marked as deletable for the next upgrade attempt? Will this flag imply --wait and then automatically delete new resources not existing before on an upgrade failure?
In --cleanup-on-fail, what are considered new resources?
Does --atomic imply --cleanup-on-fail? What does --cleanup-on-fail add to --atomic?
In all cases I could find, if a flag implies another flag, it says so in the documentation.
Force will use a replacement strategy on all resources that it finds existing already. Replacement means: If resource X exists, and the inbound version of X is different than the version in the cluster, and the two conflict, force the new X to overwrite the old X. This is the same as kubectl apply --force-conflicts, IIRC.
Atomic does not imply cleanup-on-fail
There are cases where an upgrade creates a resource that was not present in the last release. Setting this flag allows Helm to remove those new resources if the release fails. The default is to not remove them (Helm tends to avoid destruction-as-default, and give users explicit control over this)
If X is created afresh (as opposed to upgrading an existing resource), it is considered new.
Cleanup-on-fail deletes items that were marked as new. In some rare cases, it would be possible for a resource to be successfully created and then be orphaned by a rollback (if --atomic is set). If you are worried about those cases, then you could set --atomic and --cleanup-on-fail both.
Thank you for putting your mind into this @technosophos !
Ideas on docs improvements
Add all to --force description: force all resource updates through a replacement strategy
There are cases where an upgrade creates a resource that was not present in the last release. Setting this flag allows Helm to remove those new resources if the release fails.
--cleanup-on-fail allow deletion of new resources created in this upgrade when upgrade fails
Ah, I'm still quite confused about how it is works and therefor how it is suitable to use.
I now understand new resource as any resource rendered from the charts templates that was not deployed successfully by helm's latest deployment attempt.
cleanup-ON-fail suggest to me that it would cleanup on failure, but that suggest to me that we need to have the --wait flag set to monitor for failure. But, perhaps it is more like allow deletion suggest, that it is more like --cleanup-failed-new-resources-first, or that it is more like --mark-new-failed-resources-for-deletion-on-next-upgrade.
--wait if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout
Hmmm ah the missing piece of my understanding could perhaps be that --cleanup-on-fail simply will behave differently if --wait is provided due to this change of behavior with regards to marking the release as successful.
I'll make a code inspection to learn enough to dare provide a recommendation on how the helm chart I maintain should be managed in a sensible way during upgrades to avoid issues that they will have a hard time fixing.
The key issue for my Helm chart users, is without a doubt, if helm loose track of chart resources as part of an upgrade or similar. When this happen, the user which shouldn't need to know about the details within the chart, or me as a maintainer, will have a good understanding about what resources needs to be cleaned up. This is because it all depends on the transition, which depends on what was rendered in the last revision in comparison to the new attempted revision, which depends on chart version and chart values.
Code inspection insights
--cleanup-on-fail logic is triggered on install/upgrade failure (ref: code), and will cleanup resources rendered in this new revision that wasn't rendered in the last revision (ref: code).
Helm only knows about resources it has created if they are part of a successful install/upgrade, so if an upgrade has failed without --cleanup-on-fail, they will be unmanaged resources. (ref: code)
Helm will only consider an upgrade successful if run through it's install/upgrade logic without being interrupted by a call to failRelease.
Flags like --wait, or --atomic which implies --wait, will make the install/upgrade able to fail in a new way. With --wait specified, helm will wait the --timeout duration for created resources to be ready, and fail on timeout. (ref: code)
--atomic will not be influenced by --cleanup-on-fail in the rollback that apparently follow the cleanup if that happens (ref: code). And, if the --atomic invoked rollback fail, it will not --cleanup-on-fail (ref: code), even though it is possible to make part of a rollback operation (ref: code)
The state as tracked by helm, is updated on failure or on completion, but can be left as if nothing happened if is aborted with CTRL/CMD-C for example. (ref: code 1, code 2, code 3)
Summary
I think what's important for me and the users of the helm chart I maintain is to minimize the risk of creating resources that helm loose track of.
Without --cleanup-on-fail it is bound to happen
With wait --wait, we risk having it happen because a user is forced to wait until --timeout even though they have realized the upgrade is doomed to fail and want to abort it. So, they may send a termination signal to helm, which will simply kill the process which make all all progress dangling so without helm having a record of it.
With --atomic, which also implies --wait, we also get the rollback automatically invoked following the cleanup. But, during a rollback, I wonder if we may risk creating resources in a hook or similar, and they may not get cleaned up at the moment, because this rollback operation is always done without --cleanup-on-fail.
Outcome
I'll suggest all my helm chart users default to using helm install/upgrade commands with --cleanup-on-fail and without --wait / --atomic.
@technosophos could you evaluate if you think a documentation update about something specific would make sense here? I would be interested in helping out, but I would appreciate a helm maintainers directive at this point.
Reacted by Vasco Correia, Derrik Mildh, dbluxo, Steffen Gransow, Dave Cozzolino, maksagit, xiaow, Cezar Bernardi, Iban Marco, Kawhi Curry and 2 more
You have done a lot of work! Thank you! I think some documentation would be great. I think our current documentation is limited to just the basics of each of these flags. How to combine them is not documented. So that would be great.
When "cleanup" happens (eg upgrade failure), will helm exit with a "0" status code? Is there any additional message that indicates the actual upgrade failed?
Questions about helm upgrade --force that we should include in docs
PRs welcome, @saada. I'll try to answer your questions here, and I'll leave it to the community to submit those to the documentation as needed.
What happens if you don’t pass --force? Is it a kubectl patch? or a kubectl apply?
helm install and helm upgrade are more similar to a kubectl apply, though in reality the answer is neither. The resource is either created, updated (patched), or deleted.
Compare that to the two commands you listed:
><> k help patch | head -n 1
Update field(s) of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
><> k help apply | head -n 1
Apply a configuration to a resource by filename or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.
--force just tells helm to use an HTTP PUT request to Kubernetes, which is similar to kubectl apply --overwrite.
2. Can --force cause downtime to a deployment? What is the actual impact on resources?
Unless you're removing a template from the chart.... No. Again, it's the same as kubectl apply --overwrite.
3. Does it try the graceful behavior before deleting/recreating resources? Or does it always delete/recreate?
This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.
Activity
technosophos commentedon Mar 28, 2020
In all cases I could find, if a flag implies another flag, it says so in the documentation.
kubectl apply --force-conflicts, IIRC.consideRatio commentedon Mar 28, 2020
Thank you for putting your mind into this @technosophos !
Ideas on docs improvements
--forcedescription: force all resource updates through a replacement strategyAh, I'm still quite confused about how it is works and therefor how it is suitable to use.
--waitflag set to monitor for failure. But, perhaps it is more like allow deletion suggest, that it is more like--cleanup-failed-new-resources-first, or that it is more like--mark-new-failed-resources-for-deletion-on-next-upgrade.Hmmm ah the missing piece of my understanding could perhaps be that
--cleanup-on-failsimply will behave differently if--waitis provided due to this change of behavior with regards to marking the release as successful.consideRatio commentedon Apr 4, 2020
I'll make a code inspection to learn enough to dare provide a recommendation on how the helm chart I maintain should be managed in a sensible way during upgrades to avoid issues that they will have a hard time fixing.
The key issue for my Helm chart users, is without a doubt, if helm loose track of chart resources as part of an upgrade or similar. When this happen, the user which shouldn't need to know about the details within the chart, or me as a maintainer, will have a good understanding about what resources needs to be cleaned up. This is because it all depends on the transition, which depends on what was rendered in the last revision in comparison to the new attempted revision, which depends on chart version and chart values.
Code inspection insights
--cleanup-on-faillogic is triggered on install/upgrade failure (ref: code), and will cleanup resources rendered in this new revision that wasn't rendered in the last revision (ref: code).--cleanup-on-fail, they will be unmanaged resources. (ref: code)failRelease.--wait, or--atomicwhich implies--wait, will make the install/upgrade able to fail in a new way. With--waitspecified, helm will wait the--timeoutduration for created resources to be ready, and fail on timeout. (ref: code)--atomicwill not be influenced by--cleanup-on-failin the rollback that apparently follow the cleanup if that happens (ref: code). And, if the--atomicinvoked rollback fail, it will not--cleanup-on-fail(ref: code), even though it is possible to make part of a rollback operation (ref: code)CTRL/CMD-Cfor example. (ref: code 1, code 2, code 3)Summary
I think what's important for me and the users of the helm chart I maintain is to minimize the risk of creating resources that helm loose track of.
--cleanup-on-failit is bound to happen--wait, we risk having it happen because a user is forced to wait until--timeouteven though they have realized the upgrade is doomed to fail and want to abort it. So, they may send a termination signal to helm, which will simply kill the process which make all all progress dangling so without helm having a record of it.--atomic, which also implies--wait, we also get the rollback automatically invoked following the cleanup. But, during a rollback, I wonder if we may risk creating resources in a hook or similar, and they may not get cleaned up at the moment, because this rollback operation is always done without--cleanup-on-fail.Outcome
I'll suggest all my helm chart users default to using
helm install/upgradecommands with--cleanup-on-failand without--wait/--atomic.Action points ideas
--atomicis created without uninfluenced by--cleanup-on-fail, which may be an issue but I'm not 100% it is. (Potential issue: --atomic --cleanup-on-fail invoke a rollback without --cleanup-on-fail #7876)technosophos commentedon Apr 6, 2020
You have done a lot of work! Thank you! I think some documentation would be great. I think our current documentation is limited to just the basics of each of these flags. How to combine them is not documented. So that would be great.
The documentation repository is here: https://github.com/helm/helm-www/
consideRatio commentedon Apr 6, 2020
@technosophos thanks for the encouragement and pointer, and your work on this project!
isaaguilar commentedon Jul 28, 2020
When "cleanup" happens (eg upgrade failure), will helm exit with a "0" status code? Is there any additional message that indicates the actual upgrade failed?
hickeyma commentedon Jul 29, 2020
@consideRatio Did you get a chance to push a PR in docs?
saada commentedon Jul 30, 2020
Questions about
helm upgrade --forcethat we should include in docs--force? Is it akubectl patch? or akubectl apply?--forcecause downtime to a deployment? What is the actual impact on resources?--forcealso the same as kubectl’s--force? In addition to--force-conflicts?bacongobbler commentedon Jul 30, 2020
PRs welcome, @saada. I'll try to answer your questions here, and I'll leave it to the community to submit those to the documentation as needed.
helm installandhelm upgradeare more similar to akubectl apply, though in reality the answer is neither. The resource is either created, updated (patched), or deleted.Compare that to the two commands you listed:
--forcejust tells helm to use an HTTP PUT request to Kubernetes, which is similar tokubectl apply --overwrite.Unless you're removing a template from the chart.... No. Again, it's the same as
kubectl apply --overwrite.No. See #7082 (comment).
No.
kubectl apply --overwrite.consideRatio commentedon Jul 30, 2020
@hickeyma no PR has been made about this that I'm aware of. I'm not looking to make one at this point.
github-actions commentedon Oct 29, 2020
This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.
bacongobbler commentedon Nov 19, 2020
closing as stale.