-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
plugin.terraform-provider-google_v2.11.0_x4: panic: runtime error: invalid memory address or nil pointer dereference #5018
plugin.terraform-provider-google_v2.11.0_x4: panic: runtime error: invalid memory address or nil pointer dereference #5018
Comments
Maybe related to the state JSON trying to list the "instances" - and Google Compute Engine basically starting and stopping them at will? So when Terraform runs and tries to compare its state with reality there will likely be some inconsistencies?
|
I hacked the Terraform state and emptied the |
Can you check with more recent version of the provider? 2.11 is quite old. |
Hi @Chupaka - thanks. I'm a newbie, so I expected |
I tried with 3.1.0 now and it seems to still crash at the "Refreshing state..." step for google_compute_instance_template. Not sure if it is exactly the same problem but seems very similar: module.slipway-servers.google_compute_instance_template.default: Refreshing state... [id=capua-staging-instance-20191209141641307900000001] Error: rpc error: code = Unavailable desc = transport is closing panic: runtime error: invalid memory address or nil pointer dereference etc. |
@hallvors Can you post your latest config file that you tested with updated version 3.1.0? The provider was |
@edwardmedia can I share a demo project with you so you can try to reproduce? |
@hallvors yes please. Please let me know how I can repro this. |
@edwardmedia I have attempted to create a demo and zipped it up here: I have tried to remove secrets and set up a dedicated GCP project with a separate service account. Hopefully I have not published anything risky, if you spot anything let me know. Also kindly let me know when you have downloaded the zip so I can remove it just in case. (I suppose this zip now also contains some local terraform state and such.) I tried first to write a demo from scratch to keep it as simple as possible, but this approach failed to reproduce. So this is probably a bit more complex than it needs to be, but I've commented out some Ansible stuff and things that are probably not relevant. As I'm relatively new to both GCP and Terraform the approaches may not make sense :) but I hope you'll be able to reproduce the crash. Here's how to reproduce:
Usually Terraform crashes on second run of init.sh |
(I should also ofc remove that project when you're done since Google is probably charging for the test VMs :) ) |
@hallvors get the zip file. Please remove it |
Hi @hallvors . Thanks for the effort in creating a demo for us to reproduce. However, would you mind uploading your demo into a github repository or something a bit more transparent? Also, the simpler the demo, the easier it will be for us to pinpoint the root issue. Is there a way we can repro with a terraform apply instead of a shell script? On first glance, it looks like an issue outside of our provider (panic output shows a nil pointer on this line), but it will be hard to prove either way without being able to easily repro. |
Hi @c2thorn, thanks for following up. As far as I remember I set up the demo to actually create infrastructure in a (test) project on my employer's Google account, and I'm a bit worried about abuse if it's kept online. I can share the file if you email hallvord at minus dot no. The shell script runs a few Terraform init and apply commands. If you add Finally, I asked Terraform devs first and they sent me here :) |
Hey @hallvors, sorry for the delay. In order to help resolve your issue, let's figure out a way to get your configuration in a more transparent manner. Posting a terraform config will not allow other users access to your employer's infrastructure. If you remove the project/orgId, there shouldn't be any chance for malicious intent. If you are still concerned, feel free to join our slack channel and we can speak details/configurations over direct messages. |
OK @c2thorn - please clone this: Running
|
Thanks for being so cooperative @hallvors ! Just wanted to provide an update: I've been able to repro the crash by while limiting the scope down to just the |
Another update here @hallvors. This is definitely a bug, but there may be a workaround before the fix is finished. The relevant parts of the crash you are facing have to do with your Normally, Terraform would handle this situation well, but unfortunately there is some custom code written for While this most certainly should be fixed, I don't think you are actually intending to first create your |
Thanks a lot for your work on this, @c2thorn ! 🙇♂️ |
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Terraform Version
Terraform v0.12.16
Affected Resource(s)
Terraform Configuration Files
It appears to have something to do with this module - if my root module is no longer referencing this one, the crash goes away. Creating two managed instance groups with the same template should be fine, right?:
Debug Output
Console output: https://gist.github.com/hallvors/c41d3ca7bcc19fd1090f993ae25ee01a
Panic Output
https://gist.github.com/hallvors/95553bc0ac2cca81eae2f03f88d25262
Expected Behavior
No crash, completing setting up resources
Actual Behavior
Crashes consistently on apply and plan when the job is nearly finished. Deleting the state (and generated resources) makes plan work again AFAIK.
Steps to Reproduce
I mostly just run
terraform apply
with lots of
-var
statements. Backend is remote on GCP.Important Factoids
The config uses one plain google provider, one google-beta and one google with an alias (to use a different service account auth file).
References
None
The text was updated successfully, but these errors were encountered: