When removing or stopping a VM, if the container runtime returns error
because it can't find the associated VM container, the remove fails.
With this change, ignite will checks if the container runtime error is
about container not found and return without any error, no-op, letting
the operation succeed.
Before:
$ sudo ./bin/ignite rm -f my-vm2
INFO[0000] Removing the container with ID "ignite-7e6c9464555b2513" from the "cni" network
INFO[0000] CNI failed to retrieve network namespace path: container "ignite-7e6c9464555b2513" in namespace "firecracker": not found
FATA[0000] failed to kill container for VM "7e6c9464555b2513": container "ignite-7e6c9464555b2513" in namespace "firecracker": not found
After(containerd):
$ sudo ./bin/ignite rm -f my-vm2
INFO[0000] Removing the container with ID "ignite-7e6c9464555b2513" from the "cni" network
INFO[0000] CNI failed to retrieve network namespace path: container "ignite-7e6c9464555b2513" in namespace "firecracker": not found
WARN[0000] container "ignite-7e6c9464555b2513" in namespace "firecracker": not found
INFO[0000] Removed VM with name "my-vm2" and ID "7e6c9464555b2513"
Docker:
$ sudo ./bin/ignite rm -f my-vm2
INFO[0000] Removing the container with ID "ignite-7e6c9464555b2513" from the "docker-bridge" network
WARN[0000] Error response from daemon: Cannot kill container: ignite-7e6c9464555b2513: No such container: ignite-7e6c9464555b2513
INFO[0000] Removed VM with name "my-vm2" and ID "7e6c9464555b2513"
NOTE: This change avoids the usage of ifFound() in containred/client.go to keep the changes minimal for now. Using ifFound() results in a lot of code restructuring due to named error return, easily resulting in shadowed error related issues. A proper refactoring could be done separately.
When removing or stopping a VM, if the container runtime returns error because it can't find the associated VM container, the remove fails. With this change, ignite will checks if the container runtime error is about container not found and return without any error, no-op, letting the operation succeed.
Before:
After(containerd):
Docker:
NOTE: This change avoids the usage of
ifFound()
in containred/client.go to keep the changes minimal for now. UsingifFound()
results in a lot of code restructuring due to named error return, easily resulting in shadowed error related issues. A proper refactoring could be done separately.Fixes #751