Check container health as part of the deploy

After starting the containers, we should make sure they are healthy
before continuing. If any containers are unhealthy we should fail
quickly and provide output showing which container is unhealthy.

Change-Id: I785ddb45779b6699fc839fdddb9c804dd1b1da5d
This commit is contained in:
Alex Schultz 2018-05-17 09:35:51 -06:00 committed by Emilien Macchi
parent df762d810b
commit 915c1ebdd7
1 changed files with 23 additions and 0 deletions

View File

@ -221,6 +221,29 @@
when: outputs.rc is defined
failed_when: outputs.rc != 0
# We wait up to a minute for all the containers to start and output any
# containers that are unheathy. NOTE: the docker ps call always has a
# header so we use tail to skip it.
- name: "Check for unhealthy containers after step {{step}}"
shell: |
counter=0
while [ $(docker ps -f health=starting -q | wc -l) -gt 0 ] && [ $count -lt 10 ]; do
sleep 6
count=$[count+1]
done
docker ps -f health=unhealthy | tail -n +2
changed_when: false
check_mode: no
register: outputs
failed_when: false
no_log: true
become: true
- name: "Debug output for task which failed: Check for unhealthy containers after step {{step}}"
debug: var=outputs.stdout_lines|default([])|union(outputs.stderr_lines|default([]))
when: outputs.rc is defined
failed_when: outputs.rc != 0 or outputs.stdout_lines|default([]) != []
########################################################
# Bootstrap tasks, only performed on bootstrap_server_id
########################################################