-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: return error when service update triggers rollback #6757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: return error when service update triggers rollback #6757
Conversation
When a service update fails and triggers a rollback, the command now exits with code 1 instead of 0 Fixes docker#6752 Signed-off-by: Mohamed Talal Seif <mohamedtalalseif@gmail.com>
|
This is a new one, fixed the old bad PR! |
|
@thaJeztah kind remember, this is not the old bad PR, it's a new one you can review |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
I think it makes sense, but I imagine that this would be a breaking change for a lot of users. WDYT @corhere @thaJeztah? |
|
Thanks! I'll have a look at this. My main concern is that this may be a breaking change; the current behavior considers "if the service is configured to rollback on failure, then rolling back is the expected outcome" (so a zero exit code); this change changes that to consider the update / deploy to be successful. I agree that that probably would make sense, but these things can be tricky to change as it's possible people depend on this 🤔 Before this change; docker service create --name myservice --update-failure-action=rollback nginx:alpine
qcg3psc2azo9892h90e32rm8h
overall progress: 1 out of 1 tasks
1/1: running
verify: Service qcg3psc2azo9892h90e32rm8h converged
docker service update --entrypoint "exit 1" myservice
myservice
overall progress: rolling back update: 1 out of 1 tasks
1/1: running
rollback: update rolled back due to failure or early termination of task tebqn63e50c7l68dw98a4p9eu
verify: Service myservice converged
echo $?
0That said; we currently DO return a non-zero exit code when pausing the update; docker service create --name myservice --update-failure-action=pause nginx:alpine
uzdx5f97a7grbmd8dv541x8ut
overall progress: 1 out of 1 tasks
1/1: running
verify: Service uzdx5f97a7grbmd8dv541x8ut converged
docker service update --entrypoint "exit 1" myservice
myservice
overall progress: 0 out of 1 tasks
1/1: ready
service update paused: update paused due to failure or early termination of task sayp1gpmj2lspzd59ef0ktaia
echo $?
1But in that case, the service will also be in an unhealthy state; docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
uzdx5f97a7gr myservice replicated 0/1 nginx:alpine |
|
I believe patches should be backward compatible as well, but at the same moment CI/CD should react to it. One solution in my mind can't it return 0, but at the same time, show some warning about the rollback state so the pipeline can react to it? But my concern is that this may not be a consistent behaviour. |
|
(looks like I didn't refresh my browser, and missed @vvoland's comment 😅) Yeah, if we decide to go ahead, at least we shouldn't include it in a patch release, but wait to (at least) v29.3.0. |
|
Yes! Or maybe exit with 0, but throws a warning, but this may be inconsistent behaviour, if I am wrong, and this is considered a consistent behaviour, I can commit this change now |
|
Another solution is that we can add this flag
|
|
I think separate flag is fine for this for a minor release. I definitely wouldn't change that in a non-major version. |
|
No, we shouldn't add a flag specific for this case.
There's already output indicating that a rollback: update rolled back due to failure or early termination of task tebqn63e50c7l68dw98a4p9eu
service update paused: update paused due to failure or early termination of task sayp1gpmj2lspzd59ef0ktaia |
|
@thaJeztah @vvoland |
Return error when service update triggers rollback
When a service update fails and triggers a rollback, the command now
exits with code 1 instead of 0.
Fixes #6752
- What I did
Modified the
ServiceProgressfunction to return an error when a service update is rolled back, instead of returning success (nil)- How I did it
Added a check for the
rollbackflag after service convergence. Whenrollbackis true, the function now returns an error instead of nil, which causes the CLI to exit with code 1.- How to verify it
Test setup:
exit 0in healthcheckexit 1in healthcheck to trigger rollbackecho $?- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)