From dcb09e73a977a7cabd4625b489d0f1016d55e579 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Thu, 11 Jun 2015 20:56:01 -0700 Subject: [PATCH] Aggressively delete a cluster template if it exists. --- cluster/gce/util.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index ca86ab4fd98..8d1c7169952 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -401,8 +401,11 @@ function create-node-template { # add retries. Just relying on a non-zero exit code doesn't # distinguish an ephemeral failed call from a "not-exists". if gcloud compute instance-templates describe "$1" --project "${PROJECT}" &>/dev/null; then - echo "Instance template ${1} already exists; continuing." >&2 - return + echo "Instance template ${1} already exists; deleting." >&2 + if ! gcloud compute instance-templates delete "$1" --project "${PROJECT}" &>/dev/null; then + echo -e "${color_yellow}Failed to delete existing instance template${color_norm}" >&2 + exit 2 + fi fi local attempt=0