hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
612 stars 449 forks source link

Terraform crashes while running apply with a vsphere provider. #435

Closed ghost closed 6 years ago

ghost commented 6 years ago

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


Terraform Version

Terraform v0.11.4
+ provider.vsphere v1.3.3

Terraform Configuration Files

...

Debug Output

Crash Output

Error: Error applying plan:

1 error(s) occurred:

* vsphere_virtual_machine.vm: 1 error(s) occurred:

* vsphere_virtual_machine.vm: unexpected EOF

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

panic: runtime error: invalid memory address or nil pointer dereference
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1b98506]
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: goroutine 181 [running]:
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vsphere/internal/virtualdevice.(*CdromSubresource).Read(0xc4204c0958, 0xc420159100, 0xe, 0x10, 0x0, 0x0)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vsphere/internal/virtualdevice/virtual_machine_cdrom_subresource.go:448 +0x3c6
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vsphere/internal/virtualdevice.CdromPostCloneOperation(0xc420433d50, 0xc420168350, 0xc420159100, 0xe, 0x10, 0x1, 0xc420652de0, 0x1, 0x1, 0x1, ...)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vsphere/internal/virtualdevice/virtual_machine_cdrom_subresource.go:301 +0x644
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vsphere.resourceVSphereVirtualMachineCreateClone(0xc420433d50, 0x1e0e2e0, 0xc420168c20, 0x1d7d7a0, 0xc42060fda0, 0x0)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vsphere/resource_vsphere_virtual_machine.go:793 +0xd40
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vsphere.resourceVSphereVirtualMachineCreate(0xc420433d50, 0x1e0e2e0, 0xc420168c20, 0xc420433d50, 0x0)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vsphere/resource_vsphere_virtual_machine.go:222 +0x1f4
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc420560d90, 0xc42007ca00, 0xc42060f980, 0x1e0e2e0, 0xc420168c20, 0x1, 0xc42034c060, 0xc42034c060)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:227 +0x364
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc420561490, 0xc42007c910, 0xc42007ca00, 0xc42060f980, 0x335f000, 0x0, 0x18)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:283 +0xa4
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/plugin.(*ResourceProviderServer).Apply(0xc420522280, 0xc42060f520, 0xc420610690, 0x0, 0x0)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /opt/teamcity-agent/work/222ea50a1b4f75f4/src/github.com/terraform-providers/terraform-provider-vsphere/vendor/github.com/hashicorp/terraform/plugin/resource_provider.go:527 +0x57
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: reflect.Value.call(0xc4200546c0, 0xc42016a278, 0x13, 0x2096deb, 0x4, 0xc42040ef20, 0x3, 0x3, 0x0, 0x0, ...)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /usr/local/go/src/reflect/value.go:434 +0x905
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: reflect.Value.Call(0xc4200546c0, 0xc42016a278, 0x13, 0xc420483720, 0x3, 0x3, 0x0, 0x0, 0x0)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /usr/local/go/src/reflect/value.go:302 +0xa4
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: net/rpc.(*service).call(0xc4208bc700, 0xc42007c9b0, 0xc420720130, 0xc42015a200, 0xc42064e4c0, 0x1d2ad20, 0xc42060f520, 0x16, 0x1d2ad60, 0xc420610690, ...)
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /usr/local/go/src/net/rpc/server.go:381 +0x142
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: created by net/rpc.(*Server).ServeCodec
2018-03-19T10:50:43.055+0900 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4:   /usr/local/go/src/net/rpc/server.go:475 +0x36b
2018/03/19 10:50:43 [TRACE] root: eval: *terraform.EvalWriteState
2018/03/19 10:50:43 [TRACE] root: eval: *terraform.EvalApplyProvisioners
2018-03-19T10:50:43.058+0900 [DEBUG] plugin: plugin process exited: path=/Users/niko/projects/terra/vsphere/.terraform/plugins/darwin_amd64/terraform-provider-vsphere_v1.3.3_x4
2018/03/19 10:50:43 [TRACE] root: eval: *terraform.EvalIf
2018/03/19 10:50:43 [TRACE] root: eval: *terraform.EvalWriteState
2018/03/19 10:50:43 [TRACE] root: eval: *terraform.EvalWriteDiff
2018/03/19 10:50:43 [TRACE] root: eval: *terraform.EvalApplyPost
2018/03/19 10:50:43 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* vsphere_virtual_machine.vm: unexpected EOF
2018/03/19 10:50:43 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* vsphere_virtual_machine.vm: unexpected EOF
2018/03/19 10:50:43 [TRACE] [walkApply] Exiting eval tree: vsphere_virtual_machine.vm
2018/03/19 10:50:43 [TRACE] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2018/03/19 10:50:43 [TRACE] dag/walk: upstream errored, not walking "provider.vsphere (close)"
2018/03/19 10:50:43 [TRACE] dag/walk: upstream errored, not walking "root"
2018/03/19 10:50:43 [TRACE] Preserving existing state lineage "838b88b6-3380-0c14-83dc-dbaa81092228"
2018/03/19 10:50:43 [DEBUG] plugin: waiting for all plugin processes to complete...
2018-03-19T10:50:43.063+0900 [WARN ] plugin: error closing client during Kill: err="connection is shut down"

Expected Behavior

should have created a VM and started it.

Actual Behavior

vm is created but terraform crashed, network settings are not done yet it seems ?

Steps to Reproduce

  1. terraform init
  2. terraform apply

Additional Context

References

vSphere 5.5.0

emdantrim commented 6 years ago

I am getting this exact same error on vSphere 6.5, terraform v0.11.6, and vsphere provider v1.3.3.

Also occurs on: v1.3.2 v1.3.1 v1.3.0

Relevant-looking lines before the paste shown above:


2018-04-09T23:44:02.121-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 2018/04/09 23:44:02 [DEBUG] CdromPostCloneOperation: CDROM devices located: cdrom-3002
2018-04-09T23:44:02.121-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 2018/04/09 23:44:02 [DEBUG] CdromPostCloneOperation: Current resource set from configuration:
2018-04-09T23:44:02.121-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 2018/04/09 23:44:02 [DEBUG] CdromPostCloneOperation: Reading existing devices
2018-04-09T23:44:02.121-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 2018/04/09 23:44:02 [DEBUG] cdrom.0 (key 3002 at ide:1:0): Reading state
2018-04-09T23:44:02.121-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 2018/04/09 23:44:02 [DEBUG] FindVirtualDevice: Looking for device with key 3002
2018-04-09T23:44:02.121-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: 2018/04/09 23:44:02 [DEBUG] FindVirtualDevice: Device found: cdrom-3002
2018-04-09T23:44:02.123-0400 [DEBUG] plugin.terraform-provider-vsphere_v1.3.3_x4: panic: runtime error: invalid memory address or nil pointer dereference
...
hellonico commented 6 years ago

@emdantrim I worked around that specific problem by removing the CD-ROM (and the drive? not sure which one did the trick) from the original VM/template. And could go to the next step ;)

Hope this helps

emdantrim commented 6 years ago

@hellonico good to know, I'll check it out. Thanks!

vancluever commented 6 years ago

Hey all, 1.4.0 gets released today which should have a fix for this. Keep an eye out!

vancluever commented 6 years ago

Hey all! 1.4.0 was released earlier this week, so I'm just going to close this now. If anyone still has issues here please open a new issue with the new details/crash output.

Thanks!