Skip to content

ref: remove enabling --wait when --atomic is specified; fix rollback issues - #5395

Closed
bacongobbler wants to merge 3 commits into
helm:masterfrom
bacongobbler:fix-5183
Closed

bacongobbler wants to merge 3 commits into
helm:masterfrom
bacongobbler:fix-5183

Conversation

@bacongobbler

Copy link
Copy Markdown
Member

Addresses some design issues with the current --atomic flag:

  • disables the --wait flag by default. With the current design, there's no way to disable the --wait flag, and there's no technical reason why it was required in the first place. Users can opt in with helm install/upgrade --atomic --wait if they so choose.
  • fixes an issue where helm upgrade --atomic will always choose the latest revision regardless of the state it was in, and regardless if it was the release we were upgrading from. By removing the revision field to the rollbackCmd, tiller will roll back to the latest deployed release.

closes #5377

@helm-bot helm-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 4, 2019
@helm-bot helm-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 4, 2019
@bacongobbler bacongobbler added this to the 2.14.0 milestone Mar 14, 2019
@thomastaylor312

Copy link
Copy Markdown
Contributor

So for some context here, the --wait flag is required for this to work properly. The goal of the --atomic flag is to automatically roll back (or purge) when a release fails. The only way to know if a release fails is through using the --wait flag so tiller can inform the client that the release has entered a failed state

Comment thread cmd/helm/upgrade.go
timeout: u.timeout,
wait: u.wait,
description: "",
revision: releaseHistory.Releases[0].Version,

@thomastaylor312 thomastaylor312 Mar 28, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs to be here to roll back to the previous version, correct? I thought that from the code perspective, you need to set a version and that it doesn't automatically roll back, but I could totally be misremembering

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If I recall, by omitting the revision number, the last version number will be selected. I'll have to double-check this as I thought it'd fetch the latest deployed release rather than current release - 1

Basically I was trying to protect us from the following scenario:

1 -> DEPLOYED
2 -> FAILED

If we call helm upgrade --atomic in this case and it fails a second time, the assumption here is that it may roll back to version 2. I'm pretty sure we want to roll back to version 1 in this case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, as long as it fetches the last deployed release, I think it should be good

Comment thread cmd/helm/upgrade.go
force: u.force,
timeout: u.timeout,
wait: u.wait,
description: "",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of leaving this unset, should we put in a description that it was rolled back due to the atomic flag?

@helgi

helgi commented Jun 5, 2019

Copy link
Copy Markdown
Contributor

Will this get pulled into 2.14.1?

@bacongobbler

Copy link
Copy Markdown
Member Author

There's some valid design decisions pointed out by @thomastaylor312 that I need to address before this can be considered for another review. I'm not sure I have the time to work on this PR as I'm focusing on Helm 3. If you would like to work on this @helgi, you're more than welcome to :)

@bacongobbler

Copy link
Copy Markdown
Member Author

But to answer your question, no, it will not make it into 2.14.1

@mattfarina

Copy link
Copy Markdown
Collaborator

@bacongobbler can you rebase this?

@thomastaylor312

Copy link
Copy Markdown
Contributor

FWIW @mattfarina I am working on porting this to Helm 3 (with logic for handling when a previous release is broken). For Helm 2, the only open comment I worry about is this one: #5395 (comment), but things are not broken per se

Otherwise the --wait flag is required for this to work properly, so I don't know that this would add much at this point

@jdemeyer

Copy link
Copy Markdown

So for some context here, the --wait flag is required for this to work properly. The goal of the --atomic flag is to automatically roll back (or purge) when a release fails. The only way to know if a release fails is through using the --wait flag so tiller can inform the client that the release has entered a failed state

I'm not sure if it still makes sense to reply on this closed PR, but after experimenting with --atomic, we're also hitting this issue.

Basically, there are 2 different ways how helm upgrade can fail:
(1) It can fail to create the kubernetes deployment.
(2) It can successfully create the kubernetes deployment, which then fails to run properly.

What I want is a way to roll back in case (1) but not case (2) and I would expect --atomic to do that while --atomic --wait would check both (1) and (2).

@thomastaylor312

Copy link
Copy Markdown
Contributor

@jdemeyer So that distinction is interesting. I think many people would also want (2) to be atomic because if your deployment fails to run properly (but was running well before), something in your chart that changed likely caused it to fail, so it rolls back to the last successful state. Can you clarify a bit more (with a specific use case) of what kind of behavior related to (2) that you wouldn't want to rollback with on atomic? I want to make sure I fully understand before commenting further

@jdemeyer

Copy link
Copy Markdown

I'm using --atomic mainly to work around roboll/helmfile#471

The main reason that I don't like (2) is because it's slow. Our deployments take a while to start, so helm now takes considerably longer. This is essentially the issue #5377 that motivated this PR.

For staging, not rolling back deployments that fail to run also makes it much easier to debug the failed deployment.

For production, you're right: better roll back in any case.

@thomastaylor312

Copy link
Copy Markdown
Contributor

So I totally understand it being slow @jdemeyer. Like I said before in this PR though, we need to wait in order to have the signal for atomic to roll things back when things fail. I think the best option in your staging example is to make --atomic something you only specify when rolling out to prod. You can still use helm rollback in a staging type environment if helm has a non-0 exit code or if other parts of your validation fail

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

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--atomic upgrades fails due to timeout

6 participants