Repository navigation
Fix failed rollback after canceled health check - #1605
matheuscscp merged 1 commit into
Conversation
1748e27 to
d94b6c5
Compare
|
@ruslan-shaydullin Rollback tests are good. Now lets please add full coverage for the uninstall remediation too. There are two positive-negative test case pairs for the remediation being the uninstall action. One positive-negative pair for uninstall as the (only option for) remediation of install, and one positive-negative pair for uninstall as the configured remediation of upgrade. By positive-negative I mean always the question "did release inputs change or not?", which we achieve by performing the stimulation steps we did differently in the two current tests (apply a fixed revision versus just a flux CLI-like reconcile). I'm curious in seeing what will be the expected revision history and |
|
Added the uninstall tests in a9073ec, one table test with the four cases. As in the rollback tests, the two cases of a pair differ only in the stimulus, a fixed chart revision or a reconcile request annotation. Both pairs set Expected history and
Unlike the rollback, the uninstall does not wait on the interrupt context ( In the last case the controller installs the same failing chart again after the uninstall; that install fails and the release stalls. This is the existing state machine, the test only sets Since the "wait would fail" part of the guard comment only holds for the rollback, I reworded it in 7bc2777: for the uninstall the point is not to tear the release down when the new request may have changed the inputs. |
|
Cool, I think uninstall behavior is maybe not ideal but it's due to how Helm works. |
matheuscscp
left a comment
There was a problem hiding this comment.
LGTM! 🚀
Thanks @ruslan-shaydullin!
|
@ruslan-shaydullin Please squash all commits into one and force-push so I can merge 🙏 |
|
I tested this build on live cluster, and the behavior seems correct. When revision gets canceled due to new revision, only one failed revision is recorded in history. No rollbacks in between. If revision times out normally, it still rolls back as expected. Retry count still works correctly, e.g. with upgrade To be clear: I tested by changing values. I still don't fully understand the "release inputs not changed" scenario and how it can occur. |
|
Changing values is perfectly a way to "change release inputs" 👍 Thanks @artem-nefedov! |
|
Also, if last revision |
7bc2777 to
a37ae57
Compare
|
I also tested scenario where many revisions are canceled in a row (more than revision history limit). Since each cancel creates a failed revision in history, I was concerned that there will be nothing to rollback to. Thankfully, that's not the case. The last successful revision is always preserved in history, so rollback works fine. While the actual behavior is already correct, I don't think there's a test for this scenario. Would be nice to add it. The closest I found is TestSnapshots_Truncate from api/v2/snapshot_types_test.go, but it doesn't look like it tests this specific scenario. |
|
Good call @artem-nefedov! Please add this test @ruslan-shaydullin 🙏 |
|
One potentially concerning scenario that may need consideration with
Here, we have nothing to rollback. Current behavior is: second revision is treated as an upgrade, and is only attempted once. After that, helmrelease is stuck in failed state until new revision appears. Is this correct behavior? I would argue, it would've been better if it behaved same as fresh install if retries are defined (uninstall + try again from scratch, which would reset revisions/retries). That's how it works without |
|
@artem-nefedov Once again, great catch 🥇 🥇 🥇 This means we have to go back to what this PR was doing initially and bail only for rollbacks. But not the way it was being done before with if next.Type() == ReconcilerTypeRemediate &&
req.Object.GetActiveRemediation().GetStrategy() == v2.RollbackRemediationStrategy {
//...
}@ruslan-shaydullin pls 🙏 Important note here: when we introduced health check cancellation, we deliberately decided to opt uninstalls out from the cancellable context. Interrupting an uninstall is not something we need to do ever. So bailing only for rollback is the right solution, indeed! @artem-nefedov Very important question for you stemming from all these developments: Do you explicitly opt into RemediateOnFailure, or do you use the defaults? What does
I understand this only makes you half happy as you are using the cancellation one but you want the opposite of the other one. However, we have reached the conclusion that RetryOnFailure is the best default behavior for Flux, and it's a breaking change we need to do in coordination with the community. I'm considering printing a warning in helm-controller's Why is RetryOnFailure the best default: It's the simpler one, that matches kustomize-controller behavior. It assumes that simply applying the release with either new values or a new chart solves all the problems, remediations are unneeded. As you can see, remediation is a difficult framework to deal with, and it's therefore a feature for advanced users like you. So it should be opt-in. |
With CancelHealthCheckOnNewRevision enabled, a new reconcile request cancels the health check of a running upgrade and the upgrade fails. If rollback remediation is configured, the rollback starts in the same reconcile: it applies the previous manifests, waits on the already canceled context, fails as well and leaves a second failed revision behind. Requeue instead of starting the rollback when the object has been enqueued again. The next reconcile upgrades if the chart or values changed, otherwise it rolls back on a fresh context. An uninstall remediation is not interrupted and keeps running in the same reconcile. Cover rollback and uninstall remediation after a canceled health check, each with a fixed chart revision and with a reconcile request that leaves the chart and values unchanged, and a rollback after more canceled upgrades than the history limit keeps. Signed-off-by: Ruslan Shaydullin <[email protected]>
a37ae57 to
dcf0cae
Compare
|
Done in dcf0cae: the check now bails only for the rollback strategy, written the way you suggested, and the comment says so. The uninstall tests expect the uninstall to run in the canceled reconcile: with a fixed revision the fixed chart is then installed as a new release, with a reconcile request the end state is the same as before. @artem-nefedov thanks for testing. I added |
|
I'm not sure this would fix the problem I described in #1605 (comment), because uninstall and reinstall retries already worked properly as long as history has only 1 ("install") revision. The difference is that without I'm not able to test the new change right now, but might be able to later. |
|
@matheuscscp We do explicitly define remediation strategy. You can see how .spec.install and .spec.upgrade look in the description of #1557. Some apps also have upgrade retries set to 0 with We do also have apps with RetryStrategy explicitly enabled, but those are not in the scope of this issue. |
|
Sounds good @artem-nefedov, thanks for the info! It already helps. |
|
I tested the latest build. Turns out, I was wrong in my assumptions in #1605 (comment). The change did help. Now, if new revision is added before install has finished, it immediately triggers uninstall and reinstall from scratch. I think this is good. Overall, I have no remaining concerns and I believe it's good to merge. |
matheuscscp
left a comment
There was a problem hiding this comment.
LGTM! 🚀
Thanks very much for making Flux better @ruslan-shaydullin @artem-nefedov!
Fixes: #1557
With the
CancelHealthCheckOnNewRevisionfeature gate enabled and rollback remediation configured, the rollback starts in the same reconciliation in which the health check was canceled, applies the previous release, waits on the already canceled interrupt context, fails withcontext canceledand leaves a second failed release in Helm storage. After a real timeout the rollback completes.I added a check before the rollback: if the object is enqueued again, the reconciler requeues instead, regardless of why it was enqueued or why the upgrade failed, as it already does with
IsObjectEnqueuedwhenAtomicReleasereturns an error. The canceled upgrade is still recorded as a failed release. The next reconciliation upgrades if the chart or values changed, otherwise it rolls back on a fresh interrupt context. An uninstall remediation is not interrupted by the cancellation and keeps running in the same reconciliation. Resources only in the canceled release stay after that upgrade, where the failed rollback used to remove them; withRetryOnFailurethey stay on main too.