Closed daniel-milchev closed 10 months ago
Removing all containers at once in random order is a bit harsh and could lead to multiple issue and can potentially have more downsides that benefits. What could be quickly implemented and be convenient is to remove all containers with the same name. WDYT @dimitar-dimitrow
I think that it is save to remove all non running containers using an all flag. If the user insist on removing all containers(with running status as well) then the force flag should also be specified. The force flag would make the harshness of the operation visible to the user.
If the use case is to remove all containers with the same name, we should specify some new filter flag as all implies that the operation would be executed against every container. Using both name and all flags to remove all containers with some name, does not seem intuitive to me.
I know this will be used usually with test scenarios, but still my main concern is that our current implementation of remove does not send SIGKILL immediately, which can make the process to hang a lot. Also, the combination of --all --name
can lead to misunderstanding and someone may think that all containers with the given container name will be deleted.
So to summarise:
kanto-cm remove --all
will remove all not running containers, so not all at all
kanto-cm remove --all --force
will remove everything, no SIGKILL and very slow process
kanto-cm remove --all --name
?
A time flag could be added to mitigate the slow sending of SIGKILL. The combination of --all --name
should be forbidden and a descriptive error must be returned. The description of the all flag must describe that it can only be used in conjunction with force and time flags.
kanto-cm remove --all
will remove all non running containers. It is fine to leave the running ones as the default execution of remove with a single running container does not remove it as well.
kanto-cm remove --all --force
will remove everything, SIGKILL will be send after a default amount of time
kanto-cm remove --all --force --time
will remove everything, SIGKILL will be send after the provided time
It is unnecessarily complicated IMO. If we are going with this lets just use only kanto-cm remove --all
send a warning back + confirmation request and then purge all with immediate SIGKILL.
I looked into what options similar services provide, such as Podman, Docker and Kubernetes.
# Remove all containers regardless of the run state
podman rm -f -a
docker container prune [OPTIONS]
# Delete all pods, including uninitialized ones.
kubectl delete pods --all
In my personal opinion, having such a flag in this service can be quite useful and time-saving.
In a joint sync between me, @daniel-milchev and @dimitar-dimitrow we decided to do the following:
Tasks:
After that the remove
and list
commands would be able to be combined in a single command like:
kanto-cm remove $(kanto-cm list --filter status=stopped -q)
It would be convenient to be able to remove all containers at once. For example add:
The point is that when you have to remove many containers one by one it can easily get tedious.