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

panic: interface conversion: interface is nil, not string #8345

Closed
vaygr opened this issue Aug 20, 2016 · 9 comments · Fixed by #8390
Closed

panic: interface conversion: interface is nil, not string #8345

vaygr opened this issue Aug 20, 2016 · 9 comments · Fixed by #8390

Comments

@vaygr
Copy link

vaygr commented Aug 20, 2016

Terraform Version

0.7.1. Under 0.7.0 it works just fine.

Affected Resource(s)

  • google_compute_firewall

Terraform Configuration Files

The google_compute_firewall resource is simple enough and contains just 2 rules to allow incoming ports to specific instances marked by tags.

Debug Output

http://sprunge.us/fCWA

All sensitive information has been removed.

Steps to Reproduce

  1. terraform plan -target "module.firewall_gce"

References

This might be the cause or related:

@cblecker
Copy link
Contributor

Hi @vaygr!
Is it possible to provide more details around your terraform config? I just tried to duplicate this with the following, and it both planned and applied successfully:

main.tf:

variable "project_name" {
  description = "The ID of the Google Cloud project"
}

provider "google" {
  region      = "us-central1"
  project     = "${var.project_name}"
  credentials = ""
}

module "firewall_gce" {
  source = "./firewall_gce"
}

firewall_gce/main.tf:

resource "google_compute_firewall" "default1" {
  name    = "tf-firewall1"
  network = "default"

  allow {
    protocol = "tcp"
    ports    = ["80"]
  }

  source_ranges = ["0.0.0.0/0"]
  target_tags   = ["test-www-node1"]
}

resource "google_compute_firewall" "default2" {
  name    = "tf-firewall2"
  network = "default"

  allow {
    protocol = "tcp"
    ports    = ["8080"]
  }

  source_ranges = ["0.0.0.0/0"]
  target_tags   = ["test-www-node2"]
}

resource "google_compute_firewall" "default3" {
  name    = "tf-firewall3"
  network = "default"

  allow {
    protocol = "tcp"
    ports    = ["443"]
  }

  source_ranges = ["0.0.0.0/0"]
  target_tags   = ["test-www-node3"]
}

From what I can see "unexpected EOF" usually relates to an issue with your local system communicating with the provider's API. Also, what OS/arch are you running on your local system (uname -a)? I'm using Mac OS X 10.11.6 (Darwin x86_64).

@vaygr
Copy link
Author

vaygr commented Aug 20, 2016

@cblecker what if you try to apply that with 0.7.0 and then plan with 0.7.1?

@cblecker
Copy link
Contributor

Yup. Confirmed I get the same panic when I apply the config with v0.7.0, update terraform to v0.7.1, and then run a plan.

Figuring this has something to do with the state files, here's a diff on what my state looks like after a v0.7.0 apply, vs what it looks like after a fresh v0.7.1 apply: https://gist.github.com/cblecker/6837b659f2700735277057257cf48638

@cblecker
Copy link
Contributor

Okay, getting a bit closer. Creating a new build of v0.7.1 but reverting 09df0ef seems to work. Was directed to this commit by the following lines in the panic:

2016/08/20 09:03:23 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/google.convertStringArr(0xc420538240, 0x2, 0x2, 0xc4204aeda0, 0xc4202e1948, 0x1)
2016/08/20 09:03:23 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/google/resource_compute_target_pool.go:94 +0xc0
2016/08/20 09:03:23 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/google.resourceComputeFirewallAllowHash(0x279d400, 0xc42032cf00, 0xc4205380f8)
2016/08/20 09:03:23 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/google/resource_compute_firewall.go:109 +0x271

It looks like the state migration that is supposed to happen per #8236, isn't working as intended.

cc: @nwwebb as the author of the commit in question

@jen20
Copy link
Contributor

jen20 commented Aug 21, 2016

Hmm this is nasty, we'll look at fixing it up tomorrow. We are planning a 0.7.2 in fairly short order anyway, and will ensure this is resolved in that. Thanks for the detailed reproduction, it should make this reasonably straightforward to fix.

@jen20 jen20 added the crash label Aug 21, 2016
jen20 added a commit that referenced this issue Aug 22, 2016
As part of Terraform 0.7.1 it was observed in issue #8345 that the state
migration for google_compute_firewall did not appear to be running,
causing a panic when an uninitialized member was read. This commit hooks
up the state migration function (which _was_ independently unit tested
but was not actually in place).

There is currently no good test framework for this, I will address this
issue in a future RFC.
jen20 added a commit that referenced this issue Aug 23, 2016
As part of Terraform 0.7.1 it was observed in issue #8345 that the state
migration for google_compute_firewall did not appear to be running,
causing a panic when an uninitialized member was read. This commit hooks
up the state migration function (which _was_ independently unit tested
but was not actually in place).

There is currently no good test framework for this, I will address this
issue in a future RFC.
@nwwebb
Copy link
Contributor

nwwebb commented Aug 23, 2016

Sorry about that, thank you for the fix @jen20!

@asbjornenge
Copy link

I'm running into this error for (probably) some other target...?

Works fine with 0.7.0 (version used for apply), but fails for 0.7.1 and all subsequent versions (tried all up to 0.7.6).

crash.log

//cc @jen20

@cblecker
Copy link
Contributor

@asbjornenge: As this issue is closed, you may wish to open a new issue and then reference this one. There may have been a regression somewhere.

@ghost
Copy link

ghost commented Apr 21, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

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

Successfully merging a pull request may close this issue.

5 participants