Skip to content

fix upgrade of broken install - #3437

Closed
sorenmat wants to merge 2 commits into
helm:masterfrom
sorenmat:failed_deploy_fix
Closed

sorenmat wants to merge 2 commits into
helm:masterfrom
sorenmat:failed_deploy_fix

Conversation

@sorenmat

@sorenmat sorenmat commented Feb 1, 2018

Copy link
Copy Markdown

If the first upgrade --install results in a state FAILED, you can not
run the same command upgrade --install again without a failure.
This happens becuase we are search only for releases with the status DEPLOYED.
This change will if the search for DEPLOYED fails, then try to search for a release
with the state FAILED, and if found upgrade that.

This fixes issue #3353

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 1, 2018
@stealthybox

Copy link
Copy Markdown
Contributor

Thanks for submitting this patch @sorenmat

@bacongobbler

bacongobbler commented Feb 2, 2018 •

Copy link
Copy Markdown
Member

I'm very concerned about this patch's behaviour, especially since it upgrades using the configuration from the latest failed release which was the exact reason why we introduced #3097 in the first place. It's just going to re-introduce those bugs in the same manner all over again. I'm sorry, but I don't think this is the right approach at all.

@sorenmat

sorenmat commented Feb 2, 2018

Copy link
Copy Markdown
Author

ok, this was not my intention at all :)
Our problem is that in our CI/CD env, we are doing helm upgrade --install. If a developer has created a 'bad' chart/value combination, that will be deployed and fail, marking the deployment as FAILED. Then the developer fixes the issue, and tries to redeploy but that now it fails with "UPGRADE FAILED: "app" has no deployed releases" :(
Would the solution be to not use the configuration from the last release, and use the newly supplied values with the potential fix in them? (this was what I was going for, in the first place)

@bacongobbler

Copy link
Copy Markdown
Member

Yep. I mentioned the potential fix here: #3353 (comment)

Soren Mathiasen added 2 commits February 2, 2018 08:39
If the first `upgrade --install` results in a state FAILED, you can not
run the same command `upgrade --install` again without a failure.
This happens becuase we are search only for releases with the status DEPLOYED.
This change will if the search for DEPLOYED fails, then try to search for a release
with the state FAILED, and if found upgrade that.

This fixes issue helm#3353
@sorenmat

sorenmat commented Feb 5, 2018

Copy link
Copy Markdown
Author

@bacongobbler I tired to change the PR to reflect your concerns, please let me know if it looks better now.
PS: We have been running a custom build in our environment the last few days, and it seems like it has fixed the problem (doesn't mean the code is up to par though :) )

@Nowaker

Nowaker commented Feb 14, 2018

Copy link
Copy Markdown

@bacongobbler Pleaaaaaase review this. We have the same use case as @sorenmat - CI/CD.

@stealthybox

Copy link
Copy Markdown
Contributor

@Nowaker I don't believe this patch is in a ready state right now.
If you're not depending on Helm 2.8, I would downgrade to 2.7.0 for now while this gets figured out.

@sorenmat

Copy link
Copy Markdown
Author

@Nowaker could someone review it, so we can make it ready?

@bacongobbler

Copy link
Copy Markdown
Member

We're kinda busy getting prepped for the dev summit next week, but I (or someone else) can take a look at this afterwards. :)

@sorenmat

Copy link
Copy Markdown
Author

Cool, I also forgot a please in my previous message 😕

@Nowaker

Nowaker commented Feb 14, 2018

Copy link
Copy Markdown

@sorenmat Sure, do you have a binary at hand?

@sorenmat

Copy link
Copy Markdown
Author

@Nowaker you should be able to run with this
helm init --upgrade --tiller-image sorenmat/tiller:v2.8.1-upgradefix --force-upgrade --history-max=10 --service-account=tiller or what ever your configuration settings are :)

@Nowaker

Nowaker commented Feb 15, 2018

Copy link
Copy Markdown

@sorenmat I can confirm your Tiller works well and I'll keep using it until it's merged and released in Helm. 😹 Pleaaaase don't delete! Thanks!

@SHSE

SHSE commented Feb 24, 2018

Copy link
Copy Markdown

Can we merge it?

@wemu

wemu commented Feb 26, 2018

Copy link
Copy Markdown

would this also fix an upgrade that is stuck ("Error: UPGRADE FAILED: "release" has no deployed releases") even if there are succesful deployments? The history of the release shows previous revisions as status "SUPERSEDED" (at least the ones I can see with: helm history release --max=25, can't go further back due to some other error: "Error: grpc: received message larger than max"). Is "SUPERSEDED" not considered as succesful deployment?

@sorenmat

Copy link
Copy Markdown
Author

@Nowaker I wont :)

func TestStorageFailed(t *testing.T) {
storage := Init(driver.NewMemory())

const name = "angry-bird"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

}
}

func newInstallFailingKubClient() *installFailingKubeClient {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: newInstallFailingKub/e/Client

return nil, nil, err
}
} else {
// try to find a failed release we can upgrade

@bacongobbler bacongobbler Feb 27, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm sorry, but as I mentioned before, we don't want to be upgrading from a failed deploy. We want to upgrade from a completely clean state, as if this was an initial release and there were no deploys released at all. Otherwise we're just reverting back to old behaviour prior to the old PR and we're back to square one.

Is there something I'm missing here perhaps, or am I right in my initial view that this is looking for a failed deploy to upgrade from?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@bacongobbler There's a whole discussion thread about this. tl;dr upgrading from a failed state is a must-be for CI/CD environments - we need idempotent builds.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@bacongobbler I guess you can look at the issue from another angle. When we are installing the first version of the chart and the fails, why do register it at all. If we removed all traces of that deploy then we wouldn't run into this issue.
On the other hand we are loosing the track record that somebody actually tried to deploy something that failed.

@yvespp yvespp Feb 28, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@Nowaker and @sorenmat : as far as I undertand it in #3353 (comment) @bacongobbler suggested to not update from a failed release (which causes diffing with it and in turn various
other problems) but instead ignore the failed release(s) completely and treat the upgrade like a fresh install (meaning no diffing or reuse of old values). This would keep the release history intact and not require to delete a release manually that has only failed deployments.
Sorry for the interference but I have a feeling the input form @bacongobbler was overlooked and we are digging trenches for nothing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Oh, gotcha. I'm not an opponent or proponent of a particular implementation (I know nothing about Helm's internals). We just want a way to install/upgrade a chart, no matter what state it is now (if any).

@Nowaker

Nowaker commented Feb 28, 2018

Copy link
Copy Markdown

@wemu

would this also fix an upgrade that is stuck

Go try it and let us know.

If it doesn't fix the problem, you want to create a separate ticket for it. This one covers upgrades from FAILED state only.

@adamreese

Copy link
Copy Markdown
Member

Sorry to jump in late to this one...

When a failure happens during a release it is unknown what artifacts were created. If the upgrade failed part way through creating resources and you diff against what [would] be in cluster some resources will not be created.

One option would be to add a --force flag or similar to cleanup any old resources and create a fresh install

helm install --upgrade --force ...

@Nowaker

Nowaker commented Mar 1, 2018 •

Copy link
Copy Markdown

@adamreese For a CI/CD system, we wouldn't want --force to cleanup old resources IF these resources were successfully deployed, though. In short - we need one command to deploy or upgrade a Helm chart.

@bacongobbler

bacongobbler commented Mar 1, 2018 •

Copy link
Copy Markdown
Member

I can see that viewpoint. Unfortunately, we cannot accept this PR as-is due to the technical complications of upgrading from an unknown state, and after discussing with @adamreese in the dev call this morning, my earlier proposal won't work either because the release is now in an unknown state so we can't do a "vanilla" install. After the first release has failed, the cluster's state is now unknown, so we cannot install as if from a clean slate.

As far as I understand the situation, there are only two proposals that will work to resolve this for the general case:

  1. Manual intervention, same as what you'd have to do when your package manager is in an unknown state (or as Adam put it, when your git branch is in an unknown state)
  2. Automate the "purge, then re-install" workflow through a --force flag as @adamreese proposes.

Do you have alternative proposals that might work for you? Perhaps elaborating on your use case (and any others who want to chime in) might be a good way to move this forward.

@Nowaker

Nowaker commented Mar 1, 2018 •

Copy link
Copy Markdown

Option 2 - "if this is a failed deployment, purge and then deploy" inside upgrade --install - is still okay. It gets us to the point where there's only one single command to run, and it'll install or upgrade what we want, regardless of what the current state of release is (if any) - and that's a use case for everyone using Helm inside CI/CD. Thumbs way up. 👍👍👍

@bacongobbler

Copy link
Copy Markdown
Member

Okay. I'll work on an alternate PR with that feature in mind and close this one.

Thanks @sorenmat!

@stealthybox

stealthybox commented Mar 2, 2018 •

Copy link
Copy Markdown
Contributor

@bacongobbler
I'd prefer something more descriptive like --purge-initial-failures unless we think the --force flag will be used for other corner cases.

@Nowaker

Nowaker commented Mar 2, 2018

Copy link
Copy Markdown

@stealthybox 👍

@Nowaker

Nowaker commented Mar 2, 2018

Copy link
Copy Markdown

And thanks @bacongobbler!

@wemu

wemu commented Mar 5, 2018

Copy link
Copy Markdown

sorry for coming back to this. I can see the --force option will solve the majority of issues. But I don't see how persistent volumes would be treated? Some resources should not be deleted and re-created. And the helm command line seems to have no options to investigate which kubernetes resources failed to deploy within a release. So I could try fixing just that issue and re-try to install that resource to have a successful release. (this use case isn't a problem when really the first release failed, but some tool support to investigate whats broken later on during the life of an installed chart would improve the ability to act when things don't work for whatever reason). Is there some more suitable place to discuss this other then this PR?

@bacongobbler

Copy link
Copy Markdown
Member

FYI I've opened #3597 which is the follow-up to this PR.

@wemu this PR wasn't meant to solve the issues around persistent volumes, however I do know there are a few open tickets around that. Mind either commenting on those issues or opening a new ticket about your use case? Thanks!

@wemu

wemu commented Mar 5, 2018

Copy link
Copy Markdown

Thanks for the reply! I saw that other PR. Highly welcome :)

Alright! I'll dig around in the issues and see to create what I feel is missing.

@whereisaaron

Copy link
Copy Markdown
Contributor

@wemu please do cc me on the persistent volumes issue, I am struggly with that too. There are to many unrecoverable points the the helm install/upgrade workflow where you are forced to delete resources, including persistent volumes, just to complete or fix a deployment.

There is a "helm.sh/resource-policy": keep annotation (#1875) that is supposed to prevent deletion, but it also orphans resources which then clash with the next deployment attempt, and you have no way to 'import' (in terraform terms) the orphaned resource.

StatefulSets PVCs don't get deleted by helm because k8s rather than helm creates them. But this doesn't cover the use case when you have multiple replicas sharing the the same 'ReadWriteMany' or 'ReadOnlyMany' PVC. You often need a 'stateful' PVC then too, that will perisist through the helm delete --purge and helm upgrade --install cycles required to 'unstick' failed or deleted deployments.

Right now I've come to the conclusion any stateful PVCs should be kept out of your helm charts, or I guess in a helm chart just for the PVC. For NFS mounts and similar you can just directly mount them in the chart, with no PVC, which we've been doing. I'd prefer to use PVC's with efs-provisioner, but can't bend helm to these use cases without inherent risk of data loss.

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants