-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Description
We're running a docker stack deploy ... in CI/CD to deploy apps. When a service isn't updated successfully and a rollback is triggered, the deploy command still exits with code 0 indicating everything is fine. I haven't found a way to let it exit with another code, so the CI/CD pipeline can react on the deployment error (the rollback).
$ docker stack deploy --detach=false -c docker-compose.yml test-rollback
Updating service test-rollback_web (id: ximv0s6r8fgd17mdh6d100yuk)
overall progress: rolling back update: 2 out of 2 tasks
1/2: running [==================================================>]
2/2: running [==================================================>]
rollback: update rolled back due to failure or early termination of task 8jej8t73el7cgty3t5s4l6gwp
verify: Service ximv0s6r8fgd17mdh6d100yuk converged
$ echo $?
0Used docker-compose (first deploy it with exit 0 in the healthcheck, then edit to exit 1 to get a rollback on the next deployment):
$ cat docker-compose.yml
services:
web:
image: nginx:alpine
deploy:
replicas: 2
update_config:
order: start-first
failure_action: rollback
monitor: 5s
parallelism: 1
restart_policy:
condition: any
healthcheck:
# guaranteed to fail
test: ["CMD", "sh", "-c", "exit 1"]
interval: 2s
timeout: 1s
retries: 2