From 9a41d09f39c83355253836ba8044cf026e7f126c Mon Sep 17 00:00:00 2001 From: Snir Sheriber Date: Sun, 27 Dec 2020 17:42:44 +0200 Subject: [PATCH] shimv2: Avoid double removing of container from sandbox RemoveContainerRequest results in calling to deleteContainer, according to spec calling to RemoveContainer is idempotent and "must not return an error if the container has already been removed", hence, don't return error if the error reports that the container is not found. Fixes: #836 Signed-off-by: Snir Sheriber --- src/runtime/containerd-shim-v2/delete.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/runtime/containerd-shim-v2/delete.go b/src/runtime/containerd-shim-v2/delete.go index 70631c4fa..f1d7ebbc5 100644 --- a/src/runtime/containerd-shim-v2/delete.go +++ b/src/runtime/containerd-shim-v2/delete.go @@ -17,13 +17,12 @@ import ( func deleteContainer(ctx context.Context, s *service, c *container) error { if !c.cType.IsSandbox() { if c.status != task.StatusStopped { - _, err := s.sandbox.StopContainer(c.id, false) - if err != nil { + if _, err := s.sandbox.StopContainer(c.id, false); err != nil && !isNotFound(err) { return err } } - if _, err := s.sandbox.DeleteContainer(c.id); err != nil { + if _, err := s.sandbox.DeleteContainer(c.id); err != nil && !isNotFound(err) { return err } }