File tree Expand file tree Collapse file tree 1 file changed +18
-17
lines changed Expand file tree Collapse file tree 1 file changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,16 @@ func prune(id string) error {
67
67
68
68
defer bootcVM .CloseConnection ()
69
69
70
+ vmExists , err := bootcVM .Exists ()
71
+ if err != nil {
72
+ return fmt .Errorf ("unable to check if VM exists: %v" , err )
73
+ }
74
+
75
+ if ! vmExists {
76
+ logrus .Debugf ("VM %s is not running" , id )
77
+ return nil
78
+ }
79
+
70
80
if force {
71
81
err := forceKillVM (bootcVM )
72
82
if err != nil {
@@ -107,28 +117,19 @@ func pruneAll() error {
107
117
}
108
118
109
119
func killVM (bootcVM vm.BootcVM ) (err error ) {
110
- vmExists , err := bootcVM .Exists ()
120
+ var isRunning bool
121
+ isRunning , err = bootcVM .IsRunning ()
111
122
if err != nil {
112
- return fmt .Errorf ("unable to check if VM exists : %v" , err )
123
+ return fmt .Errorf ("unable to check if VM is running : %v" , err )
113
124
}
114
125
115
- if vmExists {
116
- var isRunning bool
117
- isRunning , err = bootcVM .IsRunning ()
126
+ if isRunning {
127
+ return fmt .Errorf ("VM is currently running. Stop it first or use the -f flag." )
128
+ } else {
129
+ err = bootcVM .Delete ()
118
130
if err != nil {
119
- return fmt .Errorf ("unable to check if VM is running: %v" , err )
120
- }
121
-
122
- if isRunning {
123
- return fmt .Errorf ("VM is currently running. Stop it first or use the -f flag." )
124
- } else {
125
- err = bootcVM .Delete ()
126
- if err != nil {
127
- return
128
- }
131
+ return
129
132
}
130
- } else {
131
- logrus .Infof ("VM does not exist, nothing to kill" )
132
133
}
133
134
134
135
return bootcVM .DeleteFromCache ()
You can’t perform that action at this time.
0 commit comments