From 604f5c599a1a5bd84617774b0854a3c8dae66b2b Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Thu, 7 Jan 2016 12:45:43 +0000 Subject: [PATCH] Check if there are any machines to destroy, and stop masking failures --- test/gce.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/gce.sh b/test/gce.sh index e42b9209..b40f9e20 100755 --- a/test/gce.sh +++ b/test/gce.sh @@ -34,9 +34,12 @@ function vm_names { # Delete all vms in this account function destroy { names="$(vm_names)" + if [ $(gcloud compute instances list --zone $ZONE -q $names | wc -l) -le 1 ] ; then + return 0 + fi for i in {0..10}; do # gcloud instances delete can sometimes hang. - case $(set +e; timeout 60s /bin/bash -c "gcloud compute instances delete --zone $ZONE -q $names >/dev/null 2>&1 || true"; echo $?) in + case $(set +e; timeout 60s /bin/bash -c "gcloud compute instances delete --zone $ZONE -q $names >/dev/null 2>&1"; echo $?) in 0) return 0 ;;