hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.33k stars 1.73k forks source link

Segfault in google_container_cluster datasource #10843

Open jgeorge300 opened 2 years ago

jgeorge300 commented 2 years ago

Community Note

Terraform Version

Terraform v1.1.2 on darwin_amd64

Affected Resource(s)

Terraform Configuration Files

terraform {
  required_providers {
    google-beta = {
      version = "~> 4.5"
    }
  }
}

provider {
  project = "project_name"
  region = "us-central1"
}

data "google_container_cluster" "cluster" {
  project = var.project_id
  name     = "cluster"
  location = "us-central1-f"
}

Debug Output

Debug Output

Steps to Reproduce

terraform plan or terraform import google_container_cluster.cluster $ID

Important Factoids

References

Appears related or similar to:

melinath commented 2 years ago

Relevant error:

github.com/hashicorp/terraform-provider-google/google/resource_container_node_pool.go:805 +0xb56
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2eb9a56]

terraform-provider-google/google/resource_container_node_pool.go:805

The API response prior to the segfault contained a node pool that didn't have a "management" key. I think that's probably making Management be nil on the NodePool object, which then you can't get the child of. Probably this just needs a nil check around setting nodePool["management"].

melinath commented 2 years ago

@jgeorge300 are you able to provide the actual Terraform configuration that produced this result? our tests seem like they should cover this case.

jgeorge300 commented 2 years ago

@melinath I added the missing the provider stanza. There's really not much more to this. I started with an empty terraform project and was looking to import existing infrastructure. I encountered this issue at the beginning of the process. I did have lines for adding a GCE resource to verify my permissions and configuration.