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

vSphere virtual machine must be PowerOn to destroy #7168

Closed
vipulsabhaya opened this issue Jun 14, 2016 · 1 comment · Fixed by #7206
Closed

vSphere virtual machine must be PowerOn to destroy #7168

vipulsabhaya opened this issue Jun 14, 2016 · 1 comment · Fixed by #7206

Comments

@vipulsabhaya
Copy link

Hi there,

There seems to be an issue with deleting a VM in vsphere if it's not powered on. There is logic in the 'get vm' code path that expects to find an IP. When a VM is not powered on, there is no IP available.

Terraform Version

2016/06/14 11:35:52 [INFO] Terraform version: 0.7.0 dev e7ce5a2

Affected Resource(s)

  • vsphere_virtual_machine

Debug Output

vsphere_virtual_machine.testdiskuuid: Refreshing state... (ID: vipul-testuuid) 2016/06/14 11:11:21 [DEBUG] plugin: terraform: vsphere-provider (internal) 2016/06/14 11:11:21 [DEBUG] virtual machine resource data: &schema.ResourceData{schema:map[string]*schema.Schema{"folder":(*schema.Schema)(0xc820379ce0), "linked_clone":(*schema.Schema)(0xc82037a380), "gateway":(*schema.Schema)(0xc82037a460), "custom_configuration_parameters":(*schema.Schema)(0xc82037aa80), "vcpu":(*schema.Schema)(0xc820379dc0), "domain":(*schema.Schema)(0xc82037a540), "dns_suffixes":(*schema.Schema)(0xc82037a700), "windows_opt_config":(*schema.Schema)(0xc82037ab60), "network_interface":(*schema.Schema)(0xc82037ac40), "cdrom":(*schema.Schema)(0xc82037ae00), "memory":(*schema.Schema)(0xc820379ea0), "memory_reservation":(*schema.Schema)(0xc82037a000), "datacenter":(*schema.Schema)(0xc82037a0e0), "cluster":(*schema.Schema)(0xc82037a1c0), "resource_pool":(*schema.Schema)(0xc82037a2a0), "time_zone":(*schema.Schema)(0xc82037a620), "skip_customization":(*schema.Schema)(0xc82037a8c0), "enable_disk_uuid":(*schema.Schema)(0xc82037a9a0), "name":(*schema.Schema)(0xc820379c00), "dns_servers":(*schema.Schema)(0xc82037a7e0), "disk":(*schema.Schema)(0xc82037ad20)}, config:(*terraform.ResourceConfig)(nil), state:(*terraform.InstanceState)(0xc820260940), diff:(*terraform.InstanceDiff)(nil), meta:map[string]string(nil), multiReader:(*schema.MultiLevelFieldReader)(nil), setWriter:(*schema.MapFieldWriter)(nil), newState:(*terraform.InstanceState)(nil), partial:false, partialMap:map[string]struct {}(nil), once:sync.Once{m:sync.Mutex{state:0, sema:0x0}, done:0x0}, isNew:false} 2016/06/14 11:11:25 [DEBUG] vertex root, waiting for: provider.vsphere (close) 2016/06/14 11:11:26 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.testdiskuuid 2016/06/14 11:11:30 [DEBUG] vertex root, waiting for: provider.vsphere (close) 2016/06/14 11:11:31 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.testdiskuuid 2016/06/14 11:11:35 [DEBUG] vertex root, waiting for: provider.vsphere (close) 2016/06/14 11:11:36 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.testdiskuuid 2016/06/14 11:11:40 [DEBUG] vertex root, waiting for: provider.vsphere (close) 2016/06/14 11:11:41 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.testdiskuuid 2016/06/14 11:11:45 [DEBUG] vertex root, waiting for: provider.vsphere (close) 2016/06/14 11:11:46 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.testdiskuuid 2016/06/14 11:11:50 [DEBUG] vertex root, waiting for: provider.vsphere (close) 2016/06/14 11:11:51 [DEBUG] vertex provider.vsphere (close), waiting for: vsphere_virtual_machine.testdiskuuid 2016/06/14 11:11:55 [DEBUG] vertex root, waiting for: provider.vsphere (close)

Expected Behavior

running a terraform destroy when a VM is powered off, should not wait for IP, and clean up the VM.

Actual Behavior

Terraform spins forever waiting for an IP from the node.

Steps to Reproduce

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

  1. terraform apply with a vsphere_virtual_machine resource
  2. manually power off the virtual machine
  3. terraform destroy
dkalleg added a commit to hpcloud/terraform that referenced this issue Jun 16, 2016
This patch adds a wait when powering on a vm so setupVirtualMachine does
not return until the vm is actually powered on.  This allows other
functions to work off the assumption that the current state of the vm
is not in flux. During resourceVSphereVirtualMachineRead(), the wait for
IP would cause a hang for any VM with no network interfaces or for vms
that had been powered off for any reason.  This also means that the user
could not delete a vm with no network interfaces or that is powered off.
Checking power state before trying to check for network interfaces.
Resolves hashicorp#7168
dkalleg added a commit to hpcloud/terraform that referenced this issue Jun 20, 2016
This patch adds a wait when powering on a vm so setupVirtualMachine does
not return until the vm is actually powered on.  This allows other
functions to work off the assumption that the current state of the vm
is not in flux. During resourceVSphereVirtualMachineRead(), the wait for
IP would cause a hang for any VM with no network interfaces or for vms
that had been powered off for any reason.  This also means that the user
could not delete a vm with no network interfaces or that is powered off.
Checking power state before trying to check for network interfaces.
Resolves hashicorp#7168
dkalleg added a commit to hpcloud/terraform that referenced this issue Jun 22, 2016
This patch adds a wait when powering on a vm so setupVirtualMachine does
not return until the vm is actually powered on.  This allows other
functions to work off the assumption that the current state of the vm
is not in flux. During resourceVSphereVirtualMachineRead(), the wait for
IP would cause a hang for any VM with no network interfaces or for vms
that had been powered off for any reason.  This also means that the user
could not delete a vm with no network interfaces or that is powered off.
Checking power state before trying to check for network interfaces.
Resolves hashicorp#7168
stack72 pushed a commit that referenced this issue Jul 12, 2016
…#7206)

This patch adds a wait when powering on a vm so setupVirtualMachine does
not return until the vm is actually powered on.  This allows other
functions to work off the assumption that the current state of the vm
is not in flux. During resourceVSphereVirtualMachineRead(), the wait for
IP would cause a hang for any VM with no network interfaces or for vms
that had been powered off for any reason.  This also means that the user
could not delete a vm with no network interfaces or that is powered off.
Checking power state before trying to check for network interfaces.
Resolves #7168
rachappag pushed a commit to rachi-tfproviders/vmware-vsphere that referenced this issue Apr 20, 2017
… (#7206)

This patch adds a wait when powering on a vm so setupVirtualMachine does
not return until the vm is actually powered on.  This allows other
functions to work off the assumption that the current state of the vm
is not in flux. During resourceVSphereVirtualMachineRead(), the wait for
IP would cause a hang for any VM with no network interfaces or for vms
that had been powered off for any reason.  This also means that the user
could not delete a vm with no network interfaces or that is powered off.
Checking power state before trying to check for network interfaces.
Resolves hashicorp/terraform#7168
grubernaut pushed a commit to hashicorp/terraform-provider-vsphere that referenced this issue Jun 6, 2017
… (#7206)

This patch adds a wait when powering on a vm so setupVirtualMachine does
not return until the vm is actually powered on.  This allows other
functions to work off the assumption that the current state of the vm
is not in flux. During resourceVSphereVirtualMachineRead(), the wait for
IP would cause a hang for any VM with no network interfaces or for vms
that had been powered off for any reason.  This also means that the user
could not delete a vm with no network interfaces or that is powered off.
Checking power state before trying to check for network interfaces.
Resolves hashicorp/terraform#7168
@ghost
Copy link

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

2 participants