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 panic: runtime error: index out of range #9495

Closed
Dinomoe opened this issue Oct 20, 2016 · 7 comments
Closed

Terraform panic: runtime error: index out of range #9495

Dinomoe opened this issue Oct 20, 2016 · 7 comments

Comments

@Dinomoe
Copy link

Dinomoe commented Oct 20, 2016

Hello Newb Here,

When running a terraform plan I receive a !!! TERRAFORM CRASH !!!

Troubleshooting:

  1. Upgraded to most recent version
  2. Restarted host
  3. It appears if I remove the terraform.tfsate file I can successfully run terraform plan

Original version Terraform v0.7.3
Upgraded to Terraform v0.7.7

2016/10/20 14:47:36 [DEBUG] plugin: terraform: panic: runtime error: index out of range
2016/10/20 14:47:36 [DEBUG] plugin: terraform:
2016/10/20 14:47:36 [DEBUG] plugin: terraform: goroutine 45 [running]:
2016/10/20 14:47:36 [DEBUG] plugin: terraform: panic(0x28c59c0, 0xc42000e0c0)
2016/10/20 14:47:36 [DEBUG] plugin: terraform:  /opt/go/src/runtime/panic.go:500 +0x1a1
less crash.log |grep ERROR
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalRefresh, err: vsphere_virtual_machine.mi-edge-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-edge-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalOpFilter, err: vsphere_virtual_machine.mi-edge-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-edge-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalRefresh, err: vsphere_virtual_machine.mi-control-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-control-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalOpFilter, err: vsphere_virtual_machine.mi-control-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-control-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalRefresh, err: vsphere_virtual_machine.mi-worker-nodes.0: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-worker-nodes.0: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalOpFilter, err: vsphere_virtual_machine.mi-worker-nodes.0: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-worker-nodes.0: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalRefresh, err: vsphere_virtual_machine.mi-kubeworker-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-kubeworker-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalOpFilter, err: vsphere_virtual_machine.mi-kubeworker-nodes: unexpected EOF
2016/10/20 13:55:31 [ERROR] root.vsphere-dc: eval: *terraform.EvalSequence, err: vsphere_virtual_machine.mi-kubeworker-nodes: unexpected EOF

Deploying to vSphere Resources
vsphere_virtual_machine.mi-edge-nodes
vsphere_virtual_machine.mi-control-nodes
vsphere_virtual_machine.mi-worker-nodes
vsphere_virtual_machine.mi-kubeworker-nodes

Terraform Configuration Files

vsphere.tf
https://gist.github.com/Dinomoe/73c7d70abb6127e81f773aa47c17a916

main.tf
https://gist.github.com/Dinomoe/16916ec517d67913a682e3d1124e7a2d

Debug Output

https://gist.github.com/Dinomoe/0d793c170525917eb6c8df8d5137e0ce

Panic Output

https://gist.github.com/Dinomoe/118221eb94fe3bb4180015e418772240

terraform.tfstate Output

https://gist.github.com/Dinomoe/b345aca90047c68805496263a019c166

Expected Behavior

What should have happened? Terraform Plan output expected.

Actual Behavior

What actually happened? Terraform Crash

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan
@sbourlon
Copy link

Hi @Dinomoe, I have the same issue with Terraform v0.7.7.

The panic

2016/10/20 16:01:02 [DEBUG] plugin: terraform: panic: runtime error: index out of range
2016/10/20 16:01:02 [DEBUG] plugin: terraform: 
2016/10/20 16:01:02 [DEBUG] plugin: terraform: goroutine 45 [running]:
2016/10/20 16:01:02 [DEBUG] plugin: terraform: panic(0x28c59c0, 0xc42000c0d0)
2016/10/20 16:01:02 [DEBUG] plugin: terraform:  /opt/go/src/runtime/panic.go:500 +0x1a1
2016/10/20 16:01:02 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/builtin/providers/vsphere.resourceVSphereVirtualMachineRead(0xc420397a40, 0x2e0c200, 0xc420385860, 0x1, 0x17)
2016/10/20 16:01:02 [DEBUG] plugin: terraform:  /opt/gopath/src/github.com/hashicorp/terraform/builtin/providers/vsphere/resource_vsphere_virtual_machine.go:1066 +0x3458
2016/10/20 16:01:02 [DEBUG] plugin: terraform: github.com/hashicorp/terraform/helper/schema.(*Resource).Refresh(0xc42030bc20, 0xc4201c94a0, 0x2e0c200, 0xc420385860, 0xc42032a990, 0x1, 0x0)

tells that the bug is at https://github.com/hashicorp/terraform/blob/v0.7.7/builtin/providers/vsphere/resource_vsphere_virtual_machine.go#L1066 (line 1066 in resource_vsphere_virtual_machine.go) which has been introduced by @thetuxkeeper on 2016-05-11 (see git blame).

The PR #7154 and #7760 are trying to fix your issue.

@astraios
Copy link

Same issue here, still happening with Terraform 0.8

@ghost
Copy link

ghost commented Jan 23, 2017

+1 v0.7.0 - v0.8.4 all have this issue.

@ghost
Copy link

ghost commented Jan 24, 2017

I only hit this when the Guest OS is shutdown.
The reason is that it builds an array based on the Guest network interfaces. Then later it just assumes the array populated and is ready for modifications.

With the Guest OS shutdown, there are not network interfaces, thus the array is left empty, thus an index out of bounds it thrown.

@Dinomoe
Copy link
Author

Dinomoe commented Jan 24, 2017 via email

@bamb00
Copy link

bamb00 commented Jun 9, 2017

Also getting this error in v0.9.8. Is there a solution or workaround for this issue? Thanks.

@ghost
Copy link

ghost commented Apr 10, 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 10, 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

6 participants