From 21ada131afbdfd835ac0fa768e02e133db3573ad Mon Sep 17 00:00:00 2001 From: Darren White Date: Wed, 1 Feb 2017 14:31:40 +0000 Subject: [PATCH] Don't ignore VM power on errors. This prevents Terraform from hanging indefinitely for the VM to power on. (#11604) --- .../vsphere/resource_vsphere_virtual_machine.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go index f48ece2bb9cf..816385867277 100644 --- a/builtin/providers/vsphere/resource_vsphere_virtual_machine.go +++ b/builtin/providers/vsphere/resource_vsphere_virtual_machine.go @@ -2110,7 +2110,14 @@ func (vm *virtualMachine) setupVirtualMachine(c *govmomi.Client) error { } if vm.hasBootableVmdk || vm.template != "" { - newVM.PowerOn(context.TODO()) + t, err := newVM.PowerOn(context.TODO()) + if err != nil { + return err + } + _, err = t.WaitForResult(context.TODO(), nil) + if err != nil { + return err + } err = newVM.WaitForPowerState(context.TODO(), types.VirtualMachinePowerStatePoweredOn) if err != nil { return err