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

Terraform Crash (v0.12.18) #5287

Closed
ghost opened this issue Jan 2, 2020 · 3 comments
Closed

Terraform Crash (v0.12.18) #5287

ghost opened this issue Jan 2, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 2, 2020

This issue was originally opened by @weeco as hashicorp/terraform#23744. It was migrated here as a result of the provider split. The original body of the issue is below.


Terraform Version

$ terraform -v
Terraform v0.12.18
+ provider.google v3.0.0

Terraform Configuration Files

data "google_project" "prod" {
  project_id = "redacted"
}

data "google_client_config" "current" {}

resource "google_cloud_run_service" "userpanel" {
  name     = "userpanel"
  location = var.location
  metadata {}

  template {
    spec {
      container_concurrency = 80
      service_account_name  = "[email protected]"

      containers {
        image = "redacted"

        resources {
          limits = {
            cpu    = "1000m"
            memory = "256Mi"
          }
          requests = {}
        }
      }
    }

    metadata {
      annotations = {
        "autoscaling.knative.dev/maxScale" = "10"
      }
    }
  }
}

Debug Output

Crash Output

crash.log

Expected Behavior

Terraform plan looked good (it showed one cloud run service to add) but the apply crashed.

Actual Behavior

Terraform crash after trying to apply the changes.

Steps to Reproduce

Additional Context

I tried applying this to two different Google Projects but the crash happened on both of them (I targeted them one by one by using the --target parameter).

One project already had the cloudrun service running which is why I imported the state. I saw terraform is crashing so I thought it might be because of some import / state issues. I removed the resource from my terraform module which caused the cloud run service to be deleted (as expected) and that worked. Adding the cloud run service however doesn't work because of the described crash.

References

@edwardmedia
Copy link
Contributor

@weeco Can't repro on my side. Could you post your plan result and full debug log when this happens? Thanks

@danawillow
Copy link
Contributor

This was fixed in v3.2.0 in #5094.

@edwardmedia fyi the way I was able to figure this out was by looking at the crash.log file. Since it was a crash, there is likely to be a panic in the logs, so I looked for it and found this:

2019-12-21T17:29:47.716+0100 [DEBUG] plugin.terraform-provider-google_v3.0.0_x5.exe: panic: interface conversion: interface {} is nil, not map[string]interface {}
2019-12-21T17:29:47.716+0100 [DEBUG] plugin.terraform-provider-google_v3.0.0_x5.exe: 
2019-12-21T17:29:47.716+0100 [DEBUG] plugin.terraform-provider-google_v3.0.0_x5.exe: goroutine 28 [running]:
2019-12-21T17:29:47.716+0100 [DEBUG] plugin.terraform-provider-google_v3.0.0_x5.exe: github.com/terraform-providers/terraform-provider-google/google.resourceCloudRunServiceEncoder(0xc0005f30a0, 0x1f7ea40, 0xc0005cd400, 0xc00082d740, 0x1d83d20, 0xc000355800, 0x0)
2019-12-21T17:29:47.716+0100 [DEBUG] plugin.terraform-provider-google_v3.0.0_x5.exe: 	/opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-google/google/resource_cloud_run_service.go:1946 +0x25a

This shows that there's a line in the provider that is trying to convert a variable to a map, but it can't do that because it's nil, so we need to do a nil check. Since we know what version of the provider is being used and what file and line number it's on (resource_cloud_run_service.go:1946), we can go and figure out exactly where the nil check needs to be: https://github.com/terraform-providers/terraform-provider-google/blob/v3.0.0/google/resource_cloud_run_service.go#L1946.

Now, if we take a look at the current version, we can see that the nil check is there: https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_cloud_run_service.go#L1971. From there, I used the blame view in GitHub to figure out which PR it was added in, and the CHANGELOG to figure out which release that PR appeared in. Let me know if you have any questions about that process!

@ghost
Copy link
Author

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants