Unable to detect rollbacks during "docker stack deploy" in CI/CD
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 2.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
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 $?
0
Used 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing docker stack deploy --detach=false through its service update and rollback handling, focusing on how the command determines its exit status. Reproduce the behavior with the supplied docker-compose.yml healthcheck failure and verify that a rollback is reported through a nonzero status suitable for CI/CD.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- ci-cd, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100