Closed edigaryev closed 12 months ago
Should delete
of non-existing VM return 0
from tart delete
command? What do you think? Or return exit code 2 like tart run
for an already running VM.
Or return exit code 2 like
tart run
for an already running VM.
Added in https://github.com/cirruslabs/tart/pull/597, but the thing is that we still need to avoid calling "tart stop" and "tart delete" to avoid errors in logs 🤷
This is one of those cases where both approaches have merit.
If delete
returns exit code 0:
Pros:
Cons:
If delete
returns exit code 2:
Pros:
tart run
command returns an error when a VM is already running, it would be consistent to return an error when trying to delete a non-existing VM.Cons:
delete
command multiple times can yield different outcomes.Since orchard
's objective is to maintain the state of VMs, maybe keeping the user always informed of the actual state sounds more reasonable.
@ruimarinho this is a pretty good analysis, but it's more applicable to the Tart itself rather than Orchard.
Since Orchard is supervising the Tart, it has a knowledge that some VM had never existed (in case we failed to clone it), so it's counterproductive to even try to delete that VM because this generates noise in the logs and makes users less likely to follow them.
P.S. "idempotency" issue can be easily alleviated by ignoring the exit code, e.g. in Shell scripts: tart delete <VM> || true
.
Indeed, my comment was more targeted at tart rather than orchard. Orchard should simply handle it gracefully, I agree.
Resolves https://github.com/cirruslabs/orchard/issues/120.