lima icon indicating copy to clipboard operation
lima copied to clipboard

delete all instances at once

Open developer-guy opened this issue 3 years ago • 8 comments

It'd be nice to delete all instances at once by using --all flag provided in the delete command.

$ limactl list
NAME        STATUS     SSH            ARCH      CPUS    MEMORY    DISK      DIR
buildkit    Stopped    127.0.0.1:0    x86_64    4       4GiB      100GiB    /Users/batuhan.apaydin/.lima/buildkit
default     Stopped    127.0.0.1:0    x86_64    4       4GiB      100GiB    /Users/batuhan.apaydin/.lima/default

$ limactl delete --all
INFO[0000] The QEMU process seems already stopped
INFO[0000] The host agent process seems already stopped
INFO[0000] Removing *.pid *.sock under "/Users/batuhan.apaydin/.lima/buildkit"
INFO[0000] Removing "/Users/batuhan.apaydin/.lima/buildkit/ha.sock"
INFO[0000] Deleted "buildkit" ("/Users/batuhan.apaydin/.lima/buildkit")

INFO[0000] The QEMU process seems already stopped
INFO[0000] The host agent process seems already stopped
INFO[0000] Removing *.pid *.sock under "/Users/batuhan.apaydin/.lima/default"
INFO[0000] Deleted "default" ("/Users/batuhan.apaydin/.lima/default")
  • [ ] limactl delete --all should show a warning and an "Are you sure?" prompt and require a --tty=false option to skip the prompt.
  • [ ] limactl delete --all --force, should remove all the instances even if they are working, once we remove the --force flag, it should prompt an info message to warn me there are some working instances, are you ok to delete them?
  • [ ] limactl delete --all something to be an error; if you specify --all, you must not specify any instance names.

developer-guy avatar Jan 24 '22 07:01 developer-guy

please feel free to assign it to me. I'm willing to work on that.

developer-guy avatar Jan 24 '22 07:01 developer-guy

Or use xargs ?

afbjorklund avatar Jan 24 '22 08:01 afbjorklund

Usually I just use limactl rm -f $(limactl ls -q)

AkihiroSuda avatar Jan 24 '22 08:01 AkihiroSuda

yes, both actions would work and great, but IMO, to support --all flag is the easiest way of doing this 🙈

developer-guy avatar Jan 24 '22 08:01 developer-guy

I know that podman has it, and docker does not. Seems to be mostly the tool developers, wanting the nuclear option ?

https://docs.podman.io/en/latest/markdown/podman-rm.1.html

   --all, -a
       Remove all containers.  Can be used in conjunction with -f as well.

Normally you don't have so many VMs, that it becomes an issue

afbjorklund avatar Jan 24 '22 09:01 afbjorklund

I'm unsure about making it too easy for users to blow away all their instances. I wonder if limactl delete --all should show a warning and an "Are you sure?" prompt, and require a --tty=false option to skip the prompt.

Question: what would limactl delete --all do when some instances are still running? Delete the ones that are stopped, or show and error and do nothing.

Also, I would expect limactl delete --all something to be an error; if you specify --all you must not specify any instance names.

jandubois avatar Jan 24 '22 20:01 jandubois

hello @jandubois, great advices, thank you so much. I converted them to an action item in the PR's description to specify the definition of done of the issue. ✌️

developer-guy avatar Jan 24 '22 22:01 developer-guy

  • it should prompt an info message to warn me there are some working instances, are you ok to delete them?

I think in that case the command should show an error message and tell the user to re-run the command with the --force option. It should not delete the stopped instances either when it can't delete all of them.

jandubois avatar Jan 24 '22 22:01 jandubois