Skip to content

Commit

Permalink
runtime_vm: Cleanup process when the Container is Stopped
Browse files Browse the repository at this point in the history
When the container finishes its execution a containerd-shim-kata-v2
process is left behind (only when using CRI-O).

The reason for that seems to be CRI-O not doing a cleanup of the process
whenever the container state has changed its state from running to
stopped.

The most reasonable way found to perform such cleanup seems to be taking
advantage of the goroutine used to update the container status and
performing the cleanup there, whenever it's needed.

Related: kata-containers/runtime#2719

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
(cherry picked from commit 814c1bb)
(cherry picked from commit adb657c)
  • Loading branch information
fidencio committed Aug 6, 2020
1 parent 31d4eb0 commit 345c016
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/oci/runtime_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ func (r *runtimeVM) StartContainer(c *Container) error {
if err1 := r.updateContainerStatus(c); err1 != nil {
logrus.Warningf("error updating container status %v", err1)
}

if c.state.Status == ContainerStateStopped {
if err1 := r.deleteContainer(c, true); err1 != nil {
logrus.WithError(err1).Infof("deleteContainer failed for container %s", c.ID())
}
}
}
}()

Expand Down

0 comments on commit 345c016

Please sign in to comment.