Skip to content

Commit 98a597b

Browse files
authored
Merge pull request #643 from yastij/requeue-delete
check vm existence even if machineRef is not set
2 parents 20c4893 + 4e2cead commit 98a597b

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

pkg/cloud/vsphere/services/govmomi/service.go

+11-13
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,17 @@ func (vms *VMService) DestroyVM(ctx *context.MachineContext) (infrav1.VirtualMac
135135
return vm, err
136136
}
137137

138-
// check if VM actually exists
139-
if ctx.VSphereMachine.Spec.MachineRef != "" {
140-
moRefID, err := findVMByInstanceUUID(ctx)
141-
if err != nil {
142-
return vm, err
143-
}
144-
if moRefID == "" {
145-
// No vm exists
146-
// remove the MachineRef and set the vm state to notfound
147-
ctx.VSphereMachine.Spec.MachineRef = ""
148-
vm.State = infrav1.VirtualMachineStateNotFound
149-
return vm, nil
150-
}
138+
// check if the vm existts
139+
moRefID, err := findVMByInstanceUUID(ctx)
140+
if err != nil {
141+
return vm, err
142+
}
143+
if moRefID == "" {
144+
// No vm exists
145+
// remove the MachineRef and set the vm state to notfound
146+
ctx.VSphereMachine.Spec.MachineRef = ""
147+
vm.State = infrav1.VirtualMachineStateNotFound
148+
return vm, nil
151149
}
152150

153151
// VM actually exists

0 commit comments

Comments
 (0)