Exit with error code 1 when there is failure container in gate

Change-Id: If832e5535b0788dfcfe38cd6cf88f0e0001bacd5
Closes-Bug: #1668001
(cherry picked from commit 6e41c1e326)
This commit is contained in:
Jeffrey Zhang 2017-02-26 12:02:19 +08:00
parent 9555a4f39e
commit 5ef77de231
1 changed files with 13 additions and 1 deletions

View File

@ -49,13 +49,25 @@ function check_failure {
docker images
docker ps -a
failed_containers=$(docker ps -a --format "{{.Names}}" --filter status=exited)
# 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.
failed_containers=$(docker ps -a --format "{{.Names}}" \
--filter status=created \
--filter status=restarting \
--filter status=paused \
--filter status=exited \
--filter status=dead)
for failed in ${failed_containers}; do
docker logs --tail all ${failed}
done
copy_logs
if [[ -n "$failed_containers" ]]; then
exit 1;
fi
}
function write_configs {