Clark Boylan d71b3a798d Handle no running containers during zuul graceful stop
The way the currently graceful stop tasks are written for zuul expects
there to always be a running zuul container to exec into. There are
situations where there may not be a running container in which case
there is nothing to stop. Avoid this being an error by checking if the
containers are running before execing into them. If no containers are
running then we'll noop the docker exec step allowing the rest of the
ansible tasks to continue.

Change-Id: I6c47147a589ae12cc33e37e40e49673396d120f7
2022-09-06 13:10:52 -07:00

29 lines
836 B
YAML

- name: Check if Zuul merger containers are running
# It is possible they are stopped due to some external circumstance
command:
cmd: docker-compose ps -q
chdir: /etc/zuul-merger
become: true
become_user: root
register: merger_container_list
- name: Gracefully stop Zuul Merger
shell:
cmd: docker-compose exec merger zuul-merger stop
chdir: /etc/zuul-merger
become: true
become_user: root
# Only run the docker exec command if a container is running
when: merger_container_list.stdout_lines | length > 0
- name: Wait for Zuul Merger to stop
shell:
cmd: docker-compose ps -q | xargs docker wait
chdir: /etc/zuul-merger
become: true
become_user: root
- name: Down Zuul Merger containers
shell:
cmd: docker-compose down
chdir: /etc/zuul-merger
become: true
become_user: root