From 63d7f5e7128c9505cc08b9469d6854e9d825ed4b Mon Sep 17 00:00:00 2001 From: Bharath KKB Date: Wed, 4 Nov 2020 22:30:08 -0600 Subject: [PATCH] fix: fallback to name if location is not set (#736) --- autogen/main/scripts/wait-for-cluster.sh | 7 ++++++- .../scripts/wait-for-cluster.sh | 7 ++++++- modules/beta-private-cluster/scripts/wait-for-cluster.sh | 7 ++++++- .../scripts/wait-for-cluster.sh | 7 ++++++- modules/beta-public-cluster/scripts/wait-for-cluster.sh | 7 ++++++- .../scripts/wait-for-cluster.sh | 7 ++++++- modules/private-cluster/scripts/wait-for-cluster.sh | 7 ++++++- scripts/wait-for-cluster.sh | 7 ++++++- 8 files changed, 48 insertions(+), 8 deletions(-) diff --git a/autogen/main/scripts/wait-for-cluster.sh b/autogen/main/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/autogen/main/scripts/wait-for-cluster.sh +++ b/autogen/main/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh b/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh +++ b/modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/modules/beta-private-cluster/scripts/wait-for-cluster.sh b/modules/beta-private-cluster/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/modules/beta-private-cluster/scripts/wait-for-cluster.sh +++ b/modules/beta-private-cluster/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh b/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh +++ b/modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/modules/beta-public-cluster/scripts/wait-for-cluster.sh b/modules/beta-public-cluster/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/modules/beta-public-cluster/scripts/wait-for-cluster.sh +++ b/modules/beta-public-cluster/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh b/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh +++ b/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/modules/private-cluster/scripts/wait-for-cluster.sh b/modules/private-cluster/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/modules/private-cluster/scripts/wait-for-cluster.sh +++ b/modules/private-cluster/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1 diff --git a/scripts/wait-for-cluster.sh b/scripts/wait-for-cluster.sh index a3e714428..97ee8f831 100755 --- a/scripts/wait-for-cluster.sh +++ b/scripts/wait-for-cluster.sh @@ -28,7 +28,12 @@ IMPERSONATE_SERVICE_ACCOUNT=$4 echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + # if cluster location is set, use it in filter + if [ -z "${CLUSTER_LOCATION}" ]; then + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + else + current_status=$(gcloud container clusters list --project="$PROJECT" --filter="name=$CLUSTER_NAME AND location=$CLUSTER_LOCATION" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + fi if [ -z "${current_status}" ]; then echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" exit 1