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

google_container_cluster data source does not work for some zones #11683

Closed
guhcampos opened this issue May 11, 2022 · 6 comments
Closed

google_container_cluster data source does not work for some zones #11683

guhcampos opened this issue May 11, 2022 · 6 comments

Comments

@guhcampos
Copy link

guhcampos commented May 11, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v1.1.9

Affected Resource(s)

  • google_container_cluster

Terraform Configuration Files

The actual code is big, but it boils down to just these lines:

data "google_container_cluster" "gke_publica_cluster" {
  name     = var.gke_publica_cluster_config.name
  location = "southamerica-east1-c"
  project  = var.gcp_project_id
}

data "google_container_cluster" "gke_publica_cluster2" {
  name     = var.gke_publica_cluster_config.name
  location = "us-east1-c"
  project  = var.gcp_project_id
}

Debug Output

I'm including the relevant snippet, note how the first data source clause generates a request to locations/southamerica-east1 despite referring to a specific zone, while the second does in fact look for the cluster in zones/us-east1-c.

---[ REQUEST ]---------------------------------------
GET /v1/projects/[redacted]/locations/southamerica-east1/clusters/publica-stg-gke-01?alt=json&prettyPrint=false 
[redacted]
{
  "error": {
    "code": 404,
    "message": "Not found: projects/[redacted]/locations/southamerica-east1/clusters/publica-stg-gke-01.",
    "errors": [
      {
        "message": "Not found: projects/[redacted]/locations/southamerica-east1/clusters/publica-stg-gke-01.",
        "domain": "global",
        "reason": "notFound"
      }
    ],
    "status": "NOT_FOUND"
  }
[redacted]

GET /v1/projects/[redacted]/locations/us-east1-c/clusters/publica-stg-gke-01?alt=json&prettyPrint=false HTTP/1.1
[redacted]
{
  "error": {
    "code": 404,
    "message": "Not found: projects/[redacted]/zones/us-east1-c/clusters/publica-stg-gke-01.",
    "errors": [
      {
        "message": "Not found: projects/[redacted]/zones/us-east1-c/clusters/publica-stg-gke-01.",
        "domain": "global",
        "reason": "notFound"
      }
    ],
    "status": "NOT_FOUND"
  }
}

Expected Behavior

The data source should lookup the cluster in location southamerica-east1-c, just as it did for us-east1-c

Actual Behavior

The data source looks for the cluster in southamerica-east1 - the region - even if providade with location southamerica-east1-c

Steps to Reproduce

  1. create a zonal cluster in southamerica-east1-c or any zone
  2. try to refer this cluster using the google_container_cluster data source

References

  • b/298506391
@guhcampos guhcampos added the bug label May 11, 2022
@slevenick
Copy link
Collaborator

Odd, I'm seeing this config generate the correct request:

---[ REQUEST ]---------------------------------------
GET /v1/projects/my-project/locations/southamerica-east1-c/clusters/asdf1231?alt=json&prettyPrint=false HTTP/1.1
Host: container.googleapis.com

Are you using the most recent version of the provider? (4.20.0)

Do you have default regions or zones set? I'm wondering if those are having something to do with this

@guhcampos
Copy link
Author

Hi @slevenick!

I do have a default region set in my provider, which is instantiated as such:

provider "google" {
  project = local.gcp_project_id
  region  = local.gcp_region
}```

I just tried removing it and got the very same behavior. Maybe something in my `state` could be triggering it? I can try to `state rm` and reimport a few resources if that would help. 

@slevenick
Copy link
Collaborator

Hm, yeah can you share the location and zone and region if they exist in the state for that resource?

@ironf1st
Copy link

ironf1st commented Nov 1, 2022

I ran into something similar on a multi-zone GKE cluster and thought it was a bug too. All I had to do was set the location to the region and the lookup worked. These lookups silently failing per #12873 does not help troubleshooting this at all.

@KatrinaHoffert
Copy link

@zli82016 can we get this one closed as not reproducible? We had looked into this last year in the linked bug after it was forwarded to us, but were unable to reproduce it.

@zli82016
Copy link
Collaborator

zli82016 commented Jul 8, 2024

Closing this issue as it is not reproducible.

@zli82016 zli82016 closed this as completed Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants