From 6e41c1e326cc745301966577337c65e66365d704 Mon Sep 17 00:00:00 2001
From: Jeffrey Zhang <zhang.lei.fly@gmail.com>
Date: Sun, 26 Feb 2017 12:02:19 +0800
Subject: [PATCH] Exit with error code 1 when there is failure container in
 gate

Change-Id: If832e5535b0788dfcfe38cd6cf88f0e0001bacd5
Closes-Bug: #1668001
---
 tools/deploy_aio.sh | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/deploy_aio.sh b/tools/deploy_aio.sh
index 535116544..915a54576 100755
--- a/tools/deploy_aio.sh
+++ b/tools/deploy_aio.sh
@@ -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 {
-- 
GitLab