Skip to content

Commit

Permalink
Remove() doesn't fail if the VM doesn't exist
Browse files Browse the repository at this point in the history
It avoids an error when ~/.crc/machines/crc files are present but not
the VM in Hyper-V.
crc delete continues, and deletes the config files.
  • Loading branch information
guillaumerose authored and gbraad committed Sep 7, 2021
1 parent 655578e commit 61f1a14
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/drivers/hyperv/hyperv_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ func (d *Driver) Stop() error {

// Remove removes an host
func (d *Driver) Remove() error {
if _, _, err := powershell.Execute(`Hyper-V\Get-VM`, d.MachineName, "-ErrorAction", "SilentlyContinue", "-ErrorVariable", "getVmErrors"); err != nil {
return nil
}

s, err := d.GetState()
if err != nil {
return err
Expand Down

0 comments on commit 61f1a14

Please sign in to comment.