summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhelenyao <yaohelan@huawei.com>2017-02-13 02:13:10 -0500
committerhelenyao <yaohelan@huawei.com>2017-02-13 03:57:57 -0500
commit81a982aa1dec85f0cb7ba8890de4df4c3043e1b1 (patch)
treef0bcaf0a15f591ab5bef18065bf2d901c92ab183
parent457662798a65e759b14bfc86f08afb840ea3ce46 (diff)
No action when no container is there
Docker complained about no container is there when calling the container removal step without checking the existence of container. In this change, action will be taken only if there is any container. Change-Id: I32efc98bb4e2c2f5a47bffa88fc5c5b4c8e5d821 Signed-off-by: helenyao <yaohelan@huawei.com>
-rwxr-xr-xjjb/functest/functest-cleanup.sh5
1 files changed, 4 insertions, 1 deletions
diff --git a/jjb/functest/functest-cleanup.sh b/jjb/functest/functest-cleanup.sh
index 3ef9b90dd..fc277b9ed 100755
--- a/jjb/functest/functest-cleanup.sh
+++ b/jjb/functest/functest-cleanup.sh
@@ -15,7 +15,10 @@ if [[ -n ${dangling_images} ]]; then
echo " Removing $FUNCTEST_IMAGE:<none> images and their containers..."
for image_id in "${dangling_images[@]}"; do
echo " Removing image_id: $image_id and its containers"
- docker ps -a | grep $image_id | awk '{print $1}'| xargs docker rm -f >${redirect}
+ containers=$(docker ps -a | grep $image_id | awk '{print $1}')
+ if [[ -n "$containers" ]];then
+ docker rm -f $containers >${redirect}
+ fi
docker rmi $image_id >${redirect}
done
fi