Skip to content

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

Description

@mueller-ma

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions