Skip to content

Documentation request about --cleanup-on-fail, --atomic, --force #7811

Closed

Description

@consideRatio

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

  1. Will --force use a replacement strategy for all resources no matter what?
  2. Will --atomic imply --cleanup-on-fail?
  3. 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?
  4. In --cleanup-on-fail, what are considered new resources?
  5. Does --atomic imply --cleanup-on-fail? What does --cleanup-on-fail add to --atomic?

Activity

  1. technosophos commented on Mar 28, 2020

    @technosophos
    Member

    In all cases I could find, if a flag implies another flag, it says so in the documentation.

    1. 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.
    2. Atomic does not imply cleanup-on-fail
    3. 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)
    4. If X is created afresh (as opposed to upgrading an existing resource), it is considered new.
    5. 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.
  2. consideRatio commented on Mar 28, 2020

    @consideRatio
    ContributorAuthor

    Thank you for putting your mind into this @technosophos !

    Ideas on docs improvements

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

  3. consideRatio commented on Apr 4, 2020

    @consideRatio
    ContributorAuthor

    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

    1. --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).
    2. 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)
    3. Helm will only consider an upgrade successful if run through it's install/upgrade logic without being interrupted by a call to failRelease.
    4. 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)
    5. --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)
    6. 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.

    Action points ideas

  4. technosophos commented on Apr 6, 2020

    @technosophos
    Member

    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/

  5. consideRatio commented on Apr 6, 2020

    @consideRatio
    ContributorAuthor

    @technosophos thanks for the encouragement and pointer, and your work on this project!

  6. isaaguilar commented on Jul 28, 2020

    @isaaguilar

    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?

  7. hickeyma commented on Jul 29, 2020

    @hickeyma
    Contributor

    @consideRatio Did you get a chance to push a PR in docs?

  8. saada commented on Jul 30, 2020

    @saada

    Questions about helm upgrade --force that we should include in docs

    1. What happens if you don’t pass --force? Is it a kubectl patch? or a kubectl apply?
    2. Can --force cause downtime to a deployment? What is the actual impact on resources?
    3. Does it try the graceful behavior before deleting/recreating resources? Or does it always delete/recreate?
    4. Is helm --force also the same as kubectl’s --force? In addition to --force-conflicts?
  9. bacongobbler commented on Jul 30, 2020

    @bacongobbler
    Member

    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.

    1. 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?

    No. See #7082 (comment).

    4. Is helm --force also the same as kubectl’s --force? In addition to --force-conflicts?

    No. kubectl apply --overwrite.

  10. consideRatio commented on Jul 30, 2020

    @consideRatio
    ContributorAuthor

    @consideRatio Did you get a chance to push a PR in docs?

    @hickeyma no PR has been made about this that I'm aware of. I'm not looking to make one at this point.

  11. github-actions commented on Oct 29, 2020

    @github-actions

    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.

  12. bacongobbler commented on Nov 19, 2020

    @bacongobbler
    Member

    closing as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions