Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

runtime: Handle error when container not found #809

Merged
merged 2 commits into from Mar 15, 2021

Conversation

darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Mar 13, 2021

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.

Fixes #751

@darkowlzz darkowlzz added area/UX Let's make Ignite's UX great! kind/enhancement Categorizes issue or PR as related to improving an existing feature. labels Mar 13, 2021
When removing a VM with force, if the container runtime returns error
when it can't find the associated VM container, the force 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 force remove succeed.
The behavior remains the same for non-forced remove.
Add error checks in StopContainer() and RemoveContainer() to return nil
when the container is not found. This helps avoid failure when VM stop
or remove is executed and the containers don't exist anymore, resulting
in no-op and a successful stop and remove execution.
@darkowlzz darkowlzz changed the title rm: Handle error when container not found runtime: Handle error when container not found Mar 13, 2021
@stealthybox stealthybox merged commit 2c2e4b0 into weaveworks:master Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/UX Let's make Ignite's UX great! kind/enhancement Categorizes issue or PR as related to improving an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ignite rm -f fails on dead/crashed container
2 participants