Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local.location not set in wait-for-cluster.sh script #735

Closed
pedromctech opened this issue Nov 3, 2020 · 5 comments · Fixed by #736
Closed

local.location not set in wait-for-cluster.sh script #735

pedromctech opened this issue Nov 3, 2020 · 5 comments · Fixed by #736
Assignees
Labels
bug Something isn't working

Comments

@pedromctech
Copy link

pedromctech commented Nov 3, 2020

Hi guys. I'm having this issue from today:

module.gke-cluster.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): Executing: ["/bin/sh" "-c" "PATH=/google-cloud-sdk/bin:$PATH\n.terraform/modules/gke-cluster/modules/beta-private-cluster/scripts/wait-for-cluster.sh s4nhub-production bio4n-k8s-cluster-prod\n"]
module.gke-cluster.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): Waiting for cluster s4nhub-production//bio4n-k8s-cluster-prod to reconcile...
module.gke-cluster.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): ERROR: (gcloud.container.clusters.list) Term operand expected [name=bio4n-k8s-cluster-prod AND location= *HERE*].
module.gke-cluster.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): Unable to get status for s4nhub-production//bio4n-k8s-cluster-prod
Error: Error running command 'PATH=/google-cloud-sdk/bin:$PATH
.terraform/modules/gke-cluster/modules/beta-private-cluster/scripts/wait-for-cluster.sh s4nhub-production bio4n-k8s-cluster-prod
': exit status 1. Output: Waiting for cluster s4nhub-production//bio4n-k8s-cluster-prod to reconcile...
ERROR: (gcloud.container.clusters.list) Term operand expected [name=bio4n-k8s-cluster-prod AND location= *HERE*].

This is my cluster:

module "gke-cluster" {
  source     = "github.com/terraform-google-modules/terraform-google-kubernetes-engine//modules/beta-private-cluster"
  project_id = "s4nhub-production"
  name       = join("-", ["bio4n-k8s-cluster", terraform.workspace])
  regional   = true
  region     = "us-east1"
  ...

It seems that location parameters are not being set in wait-for-cluster.sh script. Thanks for your support!

@bharathkkb
Copy link
Member

I think this maybe the destroy hook complaining as it recreates to accept location due to #734
Could you try tainting it
terraform taint module.gke-cluster.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0]

@bharathkkb bharathkkb self-assigned this Nov 3, 2020
@bharathkkb bharathkkb added the bug Something isn't working label Nov 3, 2020
@morgante
Copy link
Contributor

morgante commented Nov 3, 2020

@bharathkkb I think we'll need to make the script more robust for destroy hooks (if location isn't passed, skip that part in the filter).

@bharathkkb
Copy link
Member

@morgante yes PR incoming

@bharathkkb
Copy link
Member

@pedrodotmc could you try with the fix branch

module "gke" {
  source                 = "github.com/terraform-google-modules/terraform-google-kubernetes-engine?ref=fallback-wait-for-cluster"
....
}

I tried an upgrade from 12.0 to this branch and it works

module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0]: Destroying... [id=6413876306447008812]
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0]: Provisioning with 'local-exec'...
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0]: Destroying... [id=7056368053423075778]
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): Executing: ["/bin/sh" "-c" "PATH=/google-cloud-sdk/bin:$PATH\n.terraform/modules/example.gke/scripts/wait-for-cluster.sh project-id gke-on-vpc-cluster\n"]
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0]: Destruction complete after 0s
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): Waiting for cluster project-id//gke-on-vpc-cluster to reconcile...
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0]: Creating...
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0]: Provisioning with 'local-exec'...
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0] (local-exec): Executing: ["/bin/sh" "-c" "PATH=/google-cloud-sdk/bin:$PATH\n.terraform/modules/example.gke/scripts/wait-for-cluster.sh project-id gke-on-vpc-cluster us-east4 \n"]
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0] (local-exec): Waiting for cluster project-id/us-east4/gke-on-vpc-cluster to reconcile...
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0] (local-exec): Cluster is ready!
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0]: Destruction complete after 1s
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0]: Creating...
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_destroy_command[0]: Creation complete after 0s [id=7768141382647091032]
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0] (local-exec): Cluster is ready!
module.example.module.gke.module.gcloud_wait_for_cluster.null_resource.run_command[0]: Creation complete after 1s [id=1626491905156619176]

Apply complete! Resources: 2 added, 0 changed, 2 destroyed.

@pedromctech
Copy link
Author

Tainting resource run_destroy_command works like a charm. Thanks @bharathkkb !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants