kolla-ansible/tests/check-failure.sh
Michal Nasiadka c52a89ae04 Use Docker healthchecks for core services
This change enables the use of Docker healthchecks for core OpenStack
services.
Also check-failures.sh has been updated to treat containers with
unhealthy status as failed.

Implements: blueprint container-health-check
Change-Id: I79c6b11511ce8af70f77e2f6a490b59b477fefbb
2020-10-05 08:35:47 +00:00

36 lines
967 B
Bash
Executable File

#!/bin/bash
set -o xtrace
set -o errexit
# Enable unbuffered output for Ansible in Jenkins.
export PYTHONUNBUFFERED=1
check_failure() {
# All docker container's status are created, restarting, running, removing,
# paused, exited and dead. Containers without running status are treated as
# failure. removing is added in docker 1.13, just ignore it now.
# In addition to that, containers in unhealthy state (from healthchecks)
# are trated as failure.
failed_containers=$(sudo docker ps -a --format "{{.Names}}" \
--filter status=created \
--filter status=restarting \
--filter status=paused \
--filter status=exited \
--filter status=dead)
unhealthy_containers=$(sudo docker ps -a --format "{{.Names}}" \
--filter health=unhealthy)
if [[ -n "$failed_containers" ]]; then
exit 1;
fi
if [[ -n "$unhealthy_containers" ]]; then
exit 1;
fi
}
check_failure