Skip to content

Commit

Permalink
Refresh VM state before attempting to rm
Browse files Browse the repository at this point in the history
when a vm was running and then forceably stopped, the vm state still
appearing as running and would error when trying to remove.  a simple
refresh of the vm status fixes this.

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude authored and openshift-cherrypick-robot committed Mar 22, 2024
1 parent 71d475f commit 92fec52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/hypervctl/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,12 @@ func (vm *VirtualMachine) remove() (int32, error) {
srv *wmiext.Service
)

refreshVM, err := vm.vmm.GetMachine(vm.ElementName)
if err != nil {
return 0, err
}
// Check for disabled/stopped state
if !Disabled.equal(vm.EnabledState) {
if !Disabled.equal(refreshVM.EnabledState) {
return -1, ErrMachineStateInvalid
}
if srv, err = NewLocalHyperVService(); err != nil {
Expand Down

0 comments on commit 92fec52

Please sign in to comment.