Skip to content

Conversation

@Best2Two
Copy link

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, allowing deployment tools to detect
failures.

Fixes #6752

- What I did
Modified the ServiceProgress function in cli/command/service/progress/progress.go to return an error when automatic rollback occurs after a failed update, instead of returning success.

- How I did it
Added a check after service convergence verification. When the rollback flag is true (indicating the update was rolled back), the function returns an error, causing the CLI to exit with code 1.

- How to verify it

  1. Initialize a swarm: docker swarm init
  2. Deploy a stack with a healthy service using the docker-compose.yml from issue Unable to detect rollbacks during "docker stack deploy" in CI/CD #6752 (with exit 0 healthcheck)
  3. Update the compose file to use exit 1 in the healthcheck
  4. Run docker stack deploy --detach=false -c docker-compose.yml test-rollback
  5. The service will rollback and the command should exit with code 1
  6. Verify with echo $?

- Human readable description for the release notes

Fix `docker stack deploy` to exit with error code when service update triggers rollback

- A picture of a cute animal (not mandatory but encouraged)
🐳

@Best2Two Best2Two force-pushed the 6752-stack-deploy-rollback-exit-code branch 4 times, most recently from fd4c490 to 20c52d2 Compare January 25, 2026 18:56
@Best2Two Best2Two closed this Jan 25, 2026
@Best2Two Best2Two force-pushed the 6752-stack-deploy-rollback-exit-code branch from 20c52d2 to d5ed037 Compare January 25, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to detect rollbacks during "docker stack deploy" in CI/CD

1 participant