Skip to content

Commit

Permalink
Merge pull request #14470 from shanesmith/machine-force-remove-doesnt…
Browse files Browse the repository at this point in the history
…-stop

Stop machine before force removing files
  • Loading branch information
openshift-merge-robot authored Jun 3, 2022
2 parents 6edbf3b + b8de285 commit f7a5408
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,14 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func()
if err != nil {
return "", nil, err
}
if state == machine.Running && !opts.Force {
return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name)
if state == machine.Running {
if !opts.Force {
return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name)
}
err := v.Stop(v.Name, machine.StopOptions{})
if err != nil {
return "", nil, err
}
}

// Collect all the files that need to be destroyed
Expand Down

0 comments on commit f7a5408

Please sign in to comment.