summaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-containers.sh
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2019-03-28 08:54:53 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2019-03-29 09:21:41 +0000
commit6dfaa636400a6ad0aa42d05bea2c4b422256346c (patch)
tree411f83481da045ab19217609b3a4be9f7afc2f31 /tcwg-cleanup-stale-containers.sh
parent02a7a7652d1f1aef48c11d97ea947a7b35936066 (diff)
tcwg-cleanup-stale-containers.sh: Don't fail on dev machines
... due to present dangling volumes, which are expected on dev machines. Change-Id: Iec4aefbc025ee0546458299db442597d1fc22397
Diffstat (limited to 'tcwg-cleanup-stale-containers.sh')
-rwxr-xr-xtcwg-cleanup-stale-containers.sh22
1 files changed, 10 insertions, 12 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh
index 18710eb8..98599c49 100755
--- a/tcwg-cleanup-stale-containers.sh
+++ b/tcwg-cleanup-stale-containers.sh
@@ -151,14 +151,14 @@ do_cleanup_containers $cleanup_stopped_hours "-a" "rm -fv" "remove" "Removing co
wait $! || res=$?
status=$(($status|(2*$res)))
-rm_volumes=($($DOCKER volume ls -q -f dangling=true))
-# Filter-out named volumes like host-home and home-$USER. Leave only volumes
-# named like a sha1 hash.
-rm_volumes=($(echo "${rm_volumes[@]}" | tr " " "\n" | grep "^[a-f0-9]\{64\}\$" | cat))
-
-if [ ${#rm_volumes[@]} != 0 ]; then
- echo "Removing dangling volumes"
- if $cleanup_volumes; then
+if $cleanup_volumes; then
+ rm_volumes=($($DOCKER volume ls -q -f dangling=true))
+ # Filter-out named volumes like host-home and home-$USER. Leave only volumes
+ # named like a sha1 hash.
+ rm_volumes=($(echo "${rm_volumes[@]}" | tr " " "\n" | grep "^[a-f0-9]\{64\}\$" | cat))
+
+ if [ ${#rm_volumes[@]} != 0 ]; then
+ echo "Removing dangling volumes"
for volume in "${rm_volumes[@]}"; do
$DOCKER volume rm $volume &
res=0; wait $! || res=$?
@@ -167,11 +167,9 @@ if [ ${#rm_volumes[@]} != 0 ]; then
status=$(($status|4))
fi
done
- else
- echo "Increasing exit code to indicate dangling volumes"
- status=$(($status|4))
- echo "DRY_RUN: NOT REMOVING DANGLING VOLUMES"
fi
+else
+ echo "DRY_RUN: NOT REMOVING DANGLING VOLUMES"
fi
if $cleanup_images; then