diff --git a/net/gce.sh b/net/gce.sh index 194df18a92..e30cf8c555 100755 --- a/net/gce.sh +++ b/net/gce.sh @@ -412,7 +412,6 @@ EOF declare failOnFailure="$6" declare arrayName="$7" - # This check should eventually be moved to cloud provider specific script if [ "$publicIp" = "TERMINATED" ] || [ "$privateIp" = "TERMINATED" ]; then if $failOnFailure; then exit 1 diff --git a/net/scripts/gce-provider.sh b/net/scripts/gce-provider.sh index 2bc7d81edd..bb8af4bb70 100755 --- a/net/scripts/gce-provider.sh +++ b/net/scripts/gce-provider.sh @@ -36,6 +36,17 @@ __cloud_FindInstances() { --filter "$filter" \ --format 'value(name,networkInterfaces[0].accessConfigs[0].natIP,networkInterfaces[0].networkIP,status,zone)' \ | grep RUNNING) + + while read -r name status zone; do + privateIp=TERMINATED + publicIp=TERMINATED + printf "%-30s | publicIp=%-16s privateIp=%s status=%s zone=%s\n" "$name" "$publicIp" "$privateIp" "$status" "$zone" + + instances+=("$name:$publicIp:$privateIp:$zone") + done < <(gcloud compute instances list \ + --filter "$filter" \ + --format 'value(name,status,zone)' \ + | grep TERMINATED) } # @@ -251,6 +262,9 @@ cloud_WaitForInstanceReady() { # declare instanceZone="$3" declare timeout="$4" + if [[ $instanceIp = "TERMINATED" ]]; then + return 1 + fi timeout "${timeout}"s bash -c "set -o pipefail; until ping -c 3 $instanceIp | tr - _; do echo .; done" } @@ -268,6 +282,10 @@ cloud_FetchFile() { declare localFile="$4" declare zone="$5" + if [[ $publicIp = "TERMINATED" ]]; then + return 1 + fi + ( set -x gcloud compute scp --zone "$zone" "$instanceName:$remoteFile" "$localFile"