Skip to content

Commit

Permalink
Merge pull request #20116 from baude/hypervremoveforce
Browse files Browse the repository at this point in the history
hyperv: use StopWithForce with remove
  • Loading branch information
openshift-merge-robot authored Sep 24, 2023
2 parents 3d5b9e8 + 2bef573 commit 7359a2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 1 addition & 4 deletions pkg/machine/hyperv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,8 @@ func (v HyperVVirtualization) RemoveAndCleanMachines() error {
prevErr = handlePrevError(err, prevErr)
}

// If the VM is not stopped, we need to stop it
// TODO stop might not be enough if the state is dorked. we may need
// something like forceoff hard switch
if vm.State() != hypervctl.Disabled {
if err := vm.Stop(); err != nil {
if err := vm.StopWithForce(); err != nil {
prevErr = handlePrevError(err, prevErr)
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/machine/hyperv/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ func (m *HyperVMachine) Remove(_ string, opts machine.RemoveOptions) (string, fu
if !opts.Force {
return "", nil, &machine.ErrVMRunningCannotDestroyed{Name: m.Name}
}
if err := vm.Stop(); err != nil {
// force stop bc we are destroying
if err := vm.StopWithForce(); err != nil {
return "", nil, err
}
}
Expand Down

0 comments on commit 7359a2d

Please sign in to comment.