Repository navigation
fix(tiller): upgrade last deployed release - #3097
Conversation
bacongobbler
left a comment
There was a problem hiding this comment.
LGTM. A unit test would be great, but the code looks clear enough to me on its intent and we can write tests for it later.
| // finds the non-deleted release with the given name | ||
| currentRelease, err := s.env.Releases.Last(req.Name) | ||
| // finds the deployed release with the given name | ||
| currentRelease, err := s.env.Releases.Deployed(req.Name) |
There was a problem hiding this comment.
Would you mind adding a unit test to cover this case if possible? :)
There was a problem hiding this comment.
The change to the existing tests captures this change. Let me know if you have a different strategy in mind.
7c73cb7 to
7d7e97b
Compare
Fixes helm#2437 Two bugs were causing this behavior - Tiller was marking the previous release superseded when an upgrade failed. - Upgrade was diffing against failed releases
7d7e97b to
82ef751
Compare
|
After a 🍐 session with Adam, it does look like this fixes all four issues. The only edge case this may introduce is when a user deploys a release that initially fails then tries to upgrade to fix it, but if a chart is in that state it should be removed and re-deployed. This is a FANTASTIC change. Nice catch, @adamreese. |
|
This also appears to fix #2832. The only other bug that this does not fix is #2941 but it's still yet to be determined how a release ledger can get into a state where there are two DEPLOYED releases. A possible future fix for that would be to mark all previous deployed releases as SUPERCEDED. We did the same for Deis Workflow's release ledger IIRC and that seemed to be a good fix, if a bit hacky. |
SlickNik
left a comment
There was a problem hiding this comment.
+1 from me. As Matt said, a unit test would be nice to have. Good catch, and thanks for the fix, Adam! 👍
|
@adamreese merge when you feel like it |
|
Can't wait to try this fix - nice one guys! |
|
Thanks for this fix! Now if we can just get 3-way merge for current, new, and actual resources all our helm woes will be gone. |
|
@blakebarnett awesome to hear. Is that an open ticket somewhere or would you mind re-opening a new ticket to track that? I recall that being in a comment but I don't think we have a ticket yet. :) |
|
Yeah, that's actually what the original problem was in #2346 I believe, as mentioned here: #2341 (comment) So I guess 2 separate issues, yeah, I'll make a new one. |
|
ref: #3118 |
| if err := s.ReleaseModule.Update(originalRelease, updatedRelease, req, s.env); err != nil { | ||
| msg := fmt.Sprintf("Upgrade %q failed: %s", updatedRelease.Name, err) | ||
| s.Log("warning: %s", msg) | ||
| originalRelease.Info.Status.Code = release.Status_SUPERSEDED |
There was a problem hiding this comment.
Shouldn't the old release still be superceeded?
There was a problem hiding this comment.
if the release failed and was never deployed, the previous release is still deployed.
There was a problem hiding this comment.
Oh right; this is the error handling case. This change is correct then.
| // finds the non-deleted release with the given name | ||
| currentRelease, err := s.env.Releases.Last(req.Name) | ||
| // finds the deployed release with the given name | ||
| currentRelease, err := s.env.Releases.Deployed(req.Name) |
There was a problem hiding this comment.
If there is no "deployed" last release (ie: failed) then won't this prevent the code below from running? It seems the error handling should check for some "doesn't exist error" and if it doesn't exist, it should skip the reuseValues block, but otherwise continue.
There was a problem hiding this comment.
This is looking up what is live in the cluster to perform a diff of what needs to be installed/deleted/modified. The code below is to calculate the incremented release number
|
Using release as a reference point for diffing is to coarse and there still failure scenarios even after this fix. Tracking success state of each individual resource is the only option I see to solve it properly. Moving reference point, but leaving it on release level is not enough. Here is a failure scenario for new behavior. For resources A and B applied in the same order: At the end we have "lost" resource A0 in the cluster. which user have no way of knowing about except they go and check everything manually, despite total success reported by Helm. |
|
Hi! From now on we can't re-deploy successfully a release that previously had failed because it will fail again with the error "UPGRADE FAILED: "app" has no deployed releases". It seems that the only solution is to delete the release and relaunch it again. However, the problem in this case is: by deleting the release, the current running pods will disappear until relaunch the new one. Then, we will have an outage of the service. |
|
I agree with @redbaron, comparing to previous releases for diffing seems wrong; helm should just use the built in k8s functionality to patch and if nothing actually changes than it will effectively be a no-op. Helm shouldn't decide when to apply a diff; it should always submit to the API IMO. It would prevent this class of bugs entirely. |
|
Let's file an issue to track that proposal for Helm 3. |
|
@bacongobbler I'm testing through our pipeline and running into the issue where you can't upgrade a release that initially fails. This feels like a regression in behavior. I would be in favor of a patch for constructive behavior in this case. |
|
This introduces major regression in usability, where failed releases are rolled back by CI by deploying previous known good version and NOT using This was last straw which caused be to strip off last uses of helm and replace with ksonnet.io generated resources combined with |
|
interesting @redbaron - how are you now handling rollbacks of your deploys? |
If anybody needs to downgrade helm, here's a quick way to install v2.7.0( this change made it into both the 2.8.0 release and the patch release for 2.7.1 ) Downgrade local client: (Helm install script) Downgrade local client: (Mac using Downgrade tiller (helm server): |
|
@kiich I think most people just rollforward. If something fails, instead of a rollback, you can instead run another upgrade with the values from before, if using git, this is just a a git revert/git checkout, and re-running helm upgrade. This is why this behavior is such a huge regression, I honestly doubt many people use rollbacks, but instead just rollforward with old values. |
|
@stealthybox thank you for the feedback. I noted that we could fix that up in another comment in a different thread by saying "if no deploys have been successful, assume a vanilla install". I'm concerned around the edge cases around that scenario such as the case where users have been always deploying failed releases, but I think that it's a good suggestion point. That might handle most of the cases being brought up here. What do you think about that idea? |
|
@bacongobbler yep -- I believe that change would satisfy a lot of the need for the idempotent install/upgrade. I can see what you mean about how things might be weird in the case where a user is using the side-effects of failed deployments. Our CI pipeline reports failure to the user, but it intentionally does not clean up results so that the potentially broken environment can be studied. |
|
@redbaron So, to bring back your (and my) use-case, perhaps we need to script an automated rollback immediately after an install/upgrade failure, like what @whereisaaron suggested in an another issue? |
Fixes #2437
Two bugs were causing this behavior
failed.