Stop machine before force removing files
In #13466 the ability to force remove a machine while it's running was added but it did not first stop the machine, all files get deleted but the qemu VM would essentially be orphaned. [NO NEW TESTS NEEDED] Signed-off-by: Shane Smith <shane.smith@shopify.com>
This commit is contained in:
		
							parent
							
								
									570c2492a3
								
							
						
					
					
						commit
						b8de285a42
					
				|  | @ -831,8 +831,14 @@ func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", nil, err | 		return "", nil, err | ||||||
| 	} | 	} | ||||||
| 	if state == machine.Running && !opts.Force { | 	if state == machine.Running { | ||||||
| 		return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name) | 		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
 | 	// Collect all the files that need to be destroyed
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue