From f76e9a1e0d6ff5f0f4326bc51659027216bd8afc Mon Sep 17 00:00:00 2001
From: "Michal (inc0) Jastrzebski" <inc007@gmail.com>
Date: Tue, 14 Jun 2016 15:12:02 +0000
Subject: [PATCH] Make cleanup remove restarting/exited containers

If we have bug in contianer or it simplt somehow ended up in Exited
state, cleanup doesn't flush it. It also means it doesn't flush volumes
and that might cause an dirty env.

Closes-Bug: #1587344
Change-Id: Ib5705992500ce7efdc66509df61c381bd33d1954
---
 tools/cleanup-containers | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/cleanup-containers b/tools/cleanup-containers
index 412da2f2eb..14249c9605 100755
--- a/tools/cleanup-containers
+++ b/tools/cleanup-containers
@@ -10,7 +10,7 @@ if [ -n "$1" ]; then
     containers_to_kill=($(docker ps | grep -E "$1" | awk '{print $1}'))
     volumes_to_remove=($(docker volume ls | grep -E "$1" | awk '{print $1}'))
 else
-    containers_to_kill=$(docker ps --filter "label=kolla_version" --format "{{.Names}}")
+    containers_to_kill=$(docker ps --filter "label=kolla_version" --format "{{.Names}}" -a)
 
     volumes_to_remove=$(docker inspect -f '{{range .Mounts}} {{printf "%s\n" .Name }}{{end}}' ${containers_to_kill} | \
         egrep -v '(^\s*$)' | sort | uniq)