Files
system-config/playbooks/roles/zuul-executor/tasks/graceful.yaml
James E. Blair 98b7591902 Use docker-compose ps -qa for graceful restart
Our graceful restart scripts were written for docker-compose which,
unlike "docker", returns information about stopped containers in
the output of the "ps" subcommand.

Now that we are switching to the docker compose plugin, the ps
subcommand apparently behaves more like the docker ps command.
Update our scripts to include the "-a" argument which includes
all containers.  This works with both versions of compose.

Change-Id: I950e07ba0cb514c32410a239d92075a11a27a839
2025-06-24 09:42:29 -07:00

36 lines
1.2 KiB
YAML

- name: Check if Zuul Executor containers are running
# It is possible they are stopped due to some external circumstance.
# NOTE: docker-compose ps -qa reports exited containers
command:
cmd: docker-compose ps -qa
chdir: /etc/zuul-executor
become: true
become_user: root
register: executor_container_list
- name: Gracefully stop Zuul Executor
shell:
cmd: docker-compose exec -T executor zuul-executor graceful
chdir: /etc/zuul-executor
become: true
become_user: root
# Only run the docker exec command if a container is running
when: executor_container_list.stdout_lines | length > 0
register: ze_graceful
failed_when:
- ze_graceful.rc != 0
# If the exec fails because the container is not running we continue.
- "'No container found' not in ze_graceful.stderr"
- name: Wait for Zuul Executor to stop
shell:
cmd: docker-compose ps -qa | xargs docker wait
chdir: /etc/zuul-executor
become: true
become_user: root
when: executor_container_list.stdout_lines | length > 0
- name: Remove Zuul Executor containers
shell:
cmd: docker-compose down
chdir: /etc/zuul-executor
become: true
become_user: root