Skip to content

Commit 6682911

Browse files
authored
fix: multiple cluster wait-for-cluster.sh (#734)
1 parent 75a56f1 commit 6682911

File tree

16 files changed

+80
-40
lines changed

16 files changed

+80
-40
lines changed

autogen/main/cluster.tf.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ module "gcloud_wait_for_cluster" {
539539
upgrade = var.gcloud_upgrade
540540

541541
create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
542-
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
542+
create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
543543
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
544-
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
544+
destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
545545

546546
module_depends_on = concat(
547547
[google_container_cluster.primary.master_version],

autogen/main/scripts/wait-for-cluster.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ fi
2222

2323
PROJECT=$1
2424
CLUSTER_NAME=$2
25-
IMPERSONATE_SERVICE_ACCOUNT=$3
25+
CLUSTER_LOCATION=$3
26+
IMPERSONATE_SERVICE_ACCOUNT=$4
2627

27-
echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."
28+
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2829

2930
while
30-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
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")
32+
if [ -z "${current_status}" ]; then
33+
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
34+
exit 1
35+
fi
3136
[[ "${current_status}" != "RUNNING" ]]
3237
do printf ".";sleep 5; done
3338

cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ module "gcloud_wait_for_cluster" {
323323
upgrade = var.gcloud_upgrade
324324

325325
create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
326-
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
326+
create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
327327
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
328-
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
328+
destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
329329

330330
module_depends_on = concat(
331331
[google_container_cluster.primary.master_version],

modules/beta-private-cluster-update-variant/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ module "gcloud_wait_for_cluster" {
497497
upgrade = var.gcloud_upgrade
498498

499499
create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
500-
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
500+
create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
501501
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
502-
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
502+
destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
503503

504504
module_depends_on = concat(
505505
[google_container_cluster.primary.master_version],

modules/beta-private-cluster-update-variant/scripts/wait-for-cluster.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ fi
2222

2323
PROJECT=$1
2424
CLUSTER_NAME=$2
25-
IMPERSONATE_SERVICE_ACCOUNT=$3
25+
CLUSTER_LOCATION=$3
26+
IMPERSONATE_SERVICE_ACCOUNT=$4
2627

27-
echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."
28+
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2829

2930
while
30-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
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")
32+
if [ -z "${current_status}" ]; then
33+
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
34+
exit 1
35+
fi
3136
[[ "${current_status}" != "RUNNING" ]]
3237
do printf ".";sleep 5; done
3338

modules/beta-private-cluster/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ module "gcloud_wait_for_cluster" {
424424
upgrade = var.gcloud_upgrade
425425

426426
create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
427-
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
427+
create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
428428
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
429-
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
429+
destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
430430

431431
module_depends_on = concat(
432432
[google_container_cluster.primary.master_version],

modules/beta-private-cluster/scripts/wait-for-cluster.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ fi
2222

2323
PROJECT=$1
2424
CLUSTER_NAME=$2
25-
IMPERSONATE_SERVICE_ACCOUNT=$3
25+
CLUSTER_LOCATION=$3
26+
IMPERSONATE_SERVICE_ACCOUNT=$4
2627

27-
echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."
28+
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2829

2930
while
30-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
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")
32+
if [ -z "${current_status}" ]; then
33+
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
34+
exit 1
35+
fi
3136
[[ "${current_status}" != "RUNNING" ]]
3237
do printf ".";sleep 5; done
3338

modules/beta-public-cluster-update-variant/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,9 @@ module "gcloud_wait_for_cluster" {
478478
upgrade = var.gcloud_upgrade
479479

480480
create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
481-
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
481+
create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
482482
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
483-
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
483+
destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
484484

485485
module_depends_on = concat(
486486
[google_container_cluster.primary.master_version],

modules/beta-public-cluster-update-variant/scripts/wait-for-cluster.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@ fi
2222

2323
PROJECT=$1
2424
CLUSTER_NAME=$2
25-
IMPERSONATE_SERVICE_ACCOUNT=$3
25+
CLUSTER_LOCATION=$3
26+
IMPERSONATE_SERVICE_ACCOUNT=$4
2627

27-
echo "Waiting for cluster $CLUSTER_NAME in project $PROJECT to reconcile..."
28+
echo "Waiting for cluster $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME to reconcile..."
2829

2930
while
30-
current_status=$(gcloud container clusters list --project="$PROJECT" --filter=name:"$CLUSTER_NAME" --format="value(status)" --impersonate-service-account="$IMPERSONATE_SERVICE_ACCOUNT")
31+
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")
32+
if [ -z "${current_status}" ]; then
33+
echo "Unable to get status for $PROJECT/$CLUSTER_LOCATION/$CLUSTER_NAME"
34+
exit 1
35+
fi
3136
[[ "${current_status}" != "RUNNING" ]]
3237
do printf ".";sleep 5; done
3338

modules/beta-public-cluster/cluster.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ module "gcloud_wait_for_cluster" {
405405
upgrade = var.gcloud_upgrade
406406

407407
create_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
408-
create_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
408+
create_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
409409
destroy_cmd_entrypoint = "${path.module}/scripts/wait-for-cluster.sh"
410-
destroy_cmd_body = "${var.project_id} ${var.name} ${var.impersonate_service_account}"
410+
destroy_cmd_body = "${var.project_id} ${var.name} ${local.location} ${var.impersonate_service_account}"
411411

412412
module_depends_on = concat(
413413
[google_container_cluster.primary.master_version],

0 commit comments

Comments
 (0)