kolla-ansible/tests/check-failure.sh
Mark Goddard 3b22d334d6 CI: monasca: ignore exited monasca_thresh container
Ignore the monasca_thresh container if it is listed as exited.
The container was recently changed to operate as a 'one shot' container,
submitting a job to storm then exiting. This does not fit with the
usual pattern of Kolla Ansible container usage, but is harmless.

Depends-On: https://review.opendev.org/c/openstack/kolla/+/811977

Change-Id: Id40d2260a67ef604255fb1818d41cdcbc73164d7
2021-10-01 13:08:01 +01:00

42 lines
1.2 KiB
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 "$unhealthy_containers" ]]; then
exit 1;
fi
# NOTE(mgoddard): monasca-thresh is a one-shot container that exits but
# remains in place, leaving it with a status of exited. This is harmless.
if [[ "$failed_containers" = "monasca_thresh" ]]; then
exit 0
fi
if [[ -n "$failed_containers" ]]; then
exit 1;
fi
}
check_failure