diff --git a/autogen/main/cluster.tf.tmpl b/autogen/main/cluster.tf.tmpl index 20cbf0a42..98de1991b 100644 --- a/autogen/main/cluster.tf.tmpl +++ b/autogen/main/cluster.tf.tmpl @@ -539,9 +539,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], diff --git a/autogen/main/scripts/wait-for-cluster.sh b/autogen/main/scripts/wait-for-cluster.sh index f5049ece9..a3e714428 100755 --- a/autogen/main/scripts/wait-for-cluster.sh +++ b/autogen/main/scripts/wait-for-cluster.sh @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/cluster.tf b/cluster.tf index 243c45898..2d4cb9a1a 100644 --- a/cluster.tf +++ b/cluster.tf @@ -323,9 +323,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], diff --git a/modules/beta-private-cluster-update-variant/cluster.tf b/modules/beta-private-cluster-update-variant/cluster.tf index b9cf27b6e..192092cf3 100644 --- a/modules/beta-private-cluster-update-variant/cluster.tf +++ b/modules/beta-private-cluster-update-variant/cluster.tf @@ -497,9 +497,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], 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 f5049ece9..a3e714428 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 @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/modules/beta-private-cluster/cluster.tf b/modules/beta-private-cluster/cluster.tf index ed581a383..6ed7ef9e8 100644 --- a/modules/beta-private-cluster/cluster.tf +++ b/modules/beta-private-cluster/cluster.tf @@ -424,9 +424,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], diff --git a/modules/beta-private-cluster/scripts/wait-for-cluster.sh b/modules/beta-private-cluster/scripts/wait-for-cluster.sh index f5049ece9..a3e714428 100755 --- a/modules/beta-private-cluster/scripts/wait-for-cluster.sh +++ b/modules/beta-private-cluster/scripts/wait-for-cluster.sh @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/modules/beta-public-cluster-update-variant/cluster.tf b/modules/beta-public-cluster-update-variant/cluster.tf index ad9a3a877..e6a7b3f0c 100644 --- a/modules/beta-public-cluster-update-variant/cluster.tf +++ b/modules/beta-public-cluster-update-variant/cluster.tf @@ -478,9 +478,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], 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 f5049ece9..a3e714428 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 @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/modules/beta-public-cluster/cluster.tf b/modules/beta-public-cluster/cluster.tf index 3acae2d2c..2c1941a16 100644 --- a/modules/beta-public-cluster/cluster.tf +++ b/modules/beta-public-cluster/cluster.tf @@ -405,9 +405,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], diff --git a/modules/beta-public-cluster/scripts/wait-for-cluster.sh b/modules/beta-public-cluster/scripts/wait-for-cluster.sh index f5049ece9..a3e714428 100755 --- a/modules/beta-public-cluster/scripts/wait-for-cluster.sh +++ b/modules/beta-public-cluster/scripts/wait-for-cluster.sh @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/modules/private-cluster-update-variant/cluster.tf b/modules/private-cluster-update-variant/cluster.tf index a5eeae726..2a4a5e047 100644 --- a/modules/private-cluster-update-variant/cluster.tf +++ b/modules/private-cluster-update-variant/cluster.tf @@ -409,9 +409,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], 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 f5049ece9..a3e714428 100755 --- a/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh +++ b/modules/private-cluster-update-variant/scripts/wait-for-cluster.sh @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/modules/private-cluster/cluster.tf b/modules/private-cluster/cluster.tf index a4ca5bdc0..c2ecba747 100644 --- a/modules/private-cluster/cluster.tf +++ b/modules/private-cluster/cluster.tf @@ -336,9 +336,9 @@ module "gcloud_wait_for_cluster" { upgrade = var.gcloud_upgrade create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh" - destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}" + destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}" module_depends_on = concat( [google_container_cluster.primary.master_version], diff --git a/modules/private-cluster/scripts/wait-for-cluster.sh b/modules/private-cluster/scripts/wait-for-cluster.sh index f5049ece9..a3e714428 100755 --- a/modules/private-cluster/scripts/wait-for-cluster.sh +++ b/modules/private-cluster/scripts/wait-for-cluster.sh @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done diff --git a/scripts/wait-for-cluster.sh b/scripts/wait-for-cluster.sh index f5049ece9..a3e714428 100755 --- a/scripts/wait-for-cluster.sh +++ b/scripts/wait-for-cluster.sh @@ -22,12 +22,17 @@ fi PROJECT=$1 CLUSTER_NAME=$2 -IMPERSONATE_SERVICE_ACCOUNT=$3 +CLUSTER_LOCATION=$3 +IMPERSONATE_SERVICE_ACCOUNT=$4 -echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..." +echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..." while - current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT") + 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 [ -z "${current_status}" ]; then + echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME" + exit 1 + fi [[ "${current_status}" != "RUNNING" ]] do printf ".";sleep 5; done