Skip to content

helm upgrade --install doesn't perform an install/upgrade if the first ever install fails #3353

Closed

Description

@jstrachan

Using helm upgrade --install is a nice way to install or upgrade depending on if the release exists. But it looks like there's a bug in the logic; its not handling failed installs. In my case the first install failed; then a subsequent attempt wasn't even made as it crashes out immediately.

Maybe if the last release failed then helm upgrade --install should delete it and install again?

$ helm list
NAME           	REVISION	UPDATED                 	STATUS  	CHART                         	NAMESPACE
foo            	2       	Wed Jan 17 11:48:08 2018	FAILED	something-0.0.1                     	default

$ helm upgrade "foo" . --install 
Error: UPGRADE FAILED: "foo" has no deployed releases

Activity

  1. bacongobbler commented on Jan 17, 2018

    @bacongobbler
    Member

    This was intentional by design of #3097. Basically, diffing against a failed deployment caused undesirable behaviour, most notably this long list of bugs:

    If your initial release ends up in a failed state, we recommend purging the release via helm delete --purge foo and trying again. After a successful initial release, any subsequent failed releases will be ignored, and helm will do a diff against the last known successful release.

    Now that being said, it might be valuable to not perform a diff when no successful releases have been deployed. The experience would be the same as if the user ran helm install for the very first time in the sense that there would be no "current" release to diff against. I'd be a little concerned about certain edge cases though. @adamreese do you have any opinions on this one?

  2. chancez commented on Jan 22, 2018

    @chancez

    The suggested fix seems completely untenable in an automated system. I definitely don't want everything invoking helm to have to know about "if first release fails, delete and retry". For one, most of my tooling isn't aware if it's an install or upgrade, or if it's the first time or 100th time, it's almost always just running helm upgrade --install.

  3. chancez commented on Jan 22, 2018

    @chancez

    I'd also like to call out that I commented on the original PR #3097 (comment) asking specifically about this case.

  4. stealthybox commented on Jan 25, 2018

    @stealthybox
    Contributor

    The old behavior was better for this case.
    I agree with @chancez. This makes upgrade --install non-idempotent for a common occurrence.

    @bacongobbler
    If we're worried about releases failing and leaving shrapnel due to failed hooks, I'd say that's a design issue the chart. ( Hooks work better when they are idempotent )
    Users are free to build error handling and non-idempotent behavior around helm.

    What other edge-cases are we concerned about?
    Seems the #3097 takes care of a lot 👍

  5. bmperrea commented on Jan 31, 2018

    @bmperrea

    My local development would go much smoother if I could make helm upgrade -i be idempotent even against Failed releases for at least some combination of arguments. My use case is when I have a script of many releases that I know I want to get up to start a local development env.

    This might be analogous to the --replace flag for helm install. Note that --replace is one of only two flags from helm install that is missing in helm upgrade, the other being --name-template .

  6. bacongobbler commented on Feb 1, 2018

    @bacongobbler
    Member

    To be absolutely clear, yes this would be a good thing to fix. Anyone wanna take a crack at it while we've got our hands full with other work?

  7. added a commit that references this issue on Feb 1, 2018
  8. sorenmat commented on Feb 1, 2018

    @sorenmat

    Hi,
    I've created a PR #3437 that should fix this issue

  9. whereisaaron commented on Feb 2, 2018

    @whereisaaron
    Contributor

    I am not sure why we need the install and upgrade commands, I only ever use the upgrade --install command and is seems like a lot of people do the same. I just need one command that does upgrade --install and doesn't trip over a failed run. Can we just rename upgrade --install to deploy, make it truly idempotent, and ditch the other two?

    (I'm struggling with a new variant this problem behavior in 2.8.0. Since upgrading from 2.7.2 now if I have a failed install, and then delete --purge it, and the upgrade --install it, I can still get the Error: UPGRADE FAILED: "xyz" has no deployed releases error. Seems like --purge isn't full effective in 2.8.0 and tiller has some stuck state not showing in list --all. I have to then to a install to get tiller back to a state where I can do the usual upgrade --install again.)

  10. sorenmat commented on Feb 2, 2018

    @sorenmat

    I agree with @whereisaaron, I would be nice with a deploy command that worked more like kubectl apply. Makes automation of Helm much easier too, since you don't have to check for releases existing in some shell script madness :)

  11. added a commit that references this issue on Feb 2, 2018
  12. rchernobelskiy commented on Feb 15, 2018

    @rchernobelskiy

    Perhaps the solution is to have helm automatically run helm delete --purge?
    Something like:

    1. User executes helm upgrade --install
    2. First release fails
    3. User makes some changes to chart and executes again helm upgrade --install
    4. Helm tries to run the command
    5. It fails and there is precisely one prior release in failed state
    6. Helm silently executes helm delete --purge
    7. After purge, Helm auto-retries helm upgrade --install and shows output from that

    Perhaps this behavior could be triggered via the --force flag which already has similar behavior for other scenarios

  13. bacongobbler commented on Feb 15, 2018

    @bacongobbler
    Member

    Good idea, but I don't think we should ever delete the release ledger without the user explicitly asking to remove that data. Operators of Helm will want to learn why the service failed to upgrade from previously failed releases, or deduce failures by collecting that data from the ledger.

    I provided a comment earlier in the thread that describes a solution to the issue. It's similar to your solution in execution, but without the need to delete the entire release ledger. I believe #3437 is attempting to apply that solution as a patch.

  14. 7 remaining items

  15. RickS-C137 commented on Jan 23, 2019

    @RickS-C137

    Hello there,

    I'm using Helm 2.12.2 and still have the issue, that helm fails, when the first deployment is failed. Is this a regression maybe?

  16. eyalzek commented on Jan 30, 2019

    @eyalzek

    I'm not sure it's a regression, but that it was never actually "fixed".

  17. whereisaaron commented on Feb 4, 2019

    @whereisaaron
    Contributor

    @RickS-C137 I think this is supposed to be fixed by using helm upgrade --install --force which will 'delete' then 'install --replace' a failed release.

  18. konokimo commented on Feb 13, 2019

    @konokimo

    Still trying to fix this issue in a Jenkins Pipeline I am trying to use.
    I am trying to deploy a new image of my application and I couldn't care less if the deployment already exists or not.
    I want to run one command that either replaces the current deployment or just installs it if it does not exist.
    I tried helm install --replace I often get Error: a released named xyz is in use, cannot re-use a name that is still in use Which obviously kills my pipeline and the build fails.

  19. walkafwalka commented on Mar 2, 2019

    @walkafwalka

    @bacongobbler What do you think about #3353 (comment)?

    I do not see how there would be downtime or data loss if we destroy and recreate the initial release if the initial release fails.

  20. walkafwalka commented on Mar 3, 2019

    @walkafwalka

    I implemented this in our build:

    if helm history --max 1 "$name" 2>/dev/null | grep FAILED | cut -f1 | grep -q 1; then
        helm delete --purge "$name"
    fi
    
    helm upgrade --install --wait "$release" chart/
    
  21. whereisaaron commented on Mar 4, 2019

    @whereisaaron
    Contributor

    With helm currently, you don't know which helm command+options combination to use without inspecting the current state. And for a given helm command you don't know what you are going to get, because it depends on what the current state is. That's not really the declarative desired state dream ☁️ 💤 😄

    In helm 3 we can potentially deprecate install / upgrade / --replace / --upgrade / --force and replace them all with an idempotent helm deploy that either achieves the desired state, or leaves the state unchanged. Maybe using an algorithm similar to above, which if helm deploy fails, rolls back (revision > 1) or deletes+purges (revision = 1), to leave the state as it was before. The failed manifest would still be available via helm history/get. And there could even be a '--no-rollback' option for people who want to preserve the deployment in a failed state for investigation

    The option of helm upgrade --install --force is getting close, except that rather than rolling back and upgrading, it deletes and replaces failed releases (even for revisions >1), which makes some people angry over on #3208... 😮 ⚡️ 💥

    For right now we can use wrapper scripts or meta-tools like helmsman whose feature list is in part to employ helm but mitigate this issue:

    • Idempotency: As long your desired state file does not change, you can execute Helmsman several times and get the same result. [...regardless of the current state]
    • Continue from failures: In the case of partial deployment due to a specific chart deployment failure, fix your helm chart and execute Helmsman again without needing to rollback the partial successes first.
  22. kylecordes commented on Apr 8, 2019

    @kylecordes

    replace them all with an idempotent helm deploy that either achieves the desired state, or leaves the state unchanged

    In retrospect, this is a breathtakingly obvious design goal.

  23. dvlato commented on Jul 11, 2019

    @dvlato

    Hi,
    In our case the initial release did not really fail... It's just either that our application was not completely up when the install timeout elapsed or some other strange issue that was fixed. In any case, the application is running perfectly fine, and thus having to delete it would be a problem for us (we have some persistent storage attached that would be also removed!!) .

    Is there any workaround to deploy a chart when the initial release 'apparently failed' but it's actually ok?

  24. schollii commented on Mar 23, 2020

    @schollii

    So is the conclusion that upgrade --force is too forceful, ie there are times when a delete+replace+retry_upgrade is not correct remedy to failed upgrade?

  25. dcow commented on Jul 7, 2020

    @dcow

    Is there a separate issue tracking the idea of merging install & upgrade into a deploy command?

  26. hickeyma commented on Jul 7, 2020

    @hickeyma
    Contributor

    Not that I know of @dcow. What is the use case over helm upgrade --install command?

  27. dcow commented on Jul 7, 2020

    @dcow

    #3353 (comment)

    I am not sure why we need the install and upgrade commands, I only ever use the upgrade --install command and is seems like a lot of people do the same. I just need one command that does upgrade --install and doesn't trip over a failed run. Can we just rename upgrade --install to deploy, make it truly idempotent, and ditch the other two?
    ...

    and

    #3353 (comment)

    With helm currently, you don't know which helm command+options combination to use without inspecting the current state. And for a given helm command you don't know what you are going to get, because it depends on what the current state is. That's not really the declarative desired state dream cloud zzz smile

    In helm 3 we can potentially deprecate install / upgrade / --replace / --upgrade / --force and replace them all with an idempotent helm deploy that either achieves the desired state, or leaves the state unchanged.
    ...

    I generally agree that helm should work like kubectl apply and attempt to achieve the desired reality rather than needing to run different types of commands depending on the state of your cluster. Was hoping to add support to a dedicated issue if one existed or at least figure out what the resolution was since deploy is not currently implemented and we're on helm 3.2.

  28. hickeyma commented on Jul 7, 2020

    @hickeyma
    Contributor

    @dcow Ok, do you want to create an issue then with your proposal?

  29. dcow commented on Jul 8, 2020

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions