diff --git a/server/container_create.go b/server/container_create.go index 1072fac9271..bf998fe5c15 100644 --- a/server/container_create.go +++ b/server/container_create.go @@ -27,6 +27,9 @@ import ( "github.com/pkg/errors" ) +// sync with https://github.com/containers/storage/blob/7fe03f6c765f2adbc75a5691a1fb4f19e56e7071/pkg/truncindex/truncindex.go#L92 +const noSuchID = "no such id" + type orderedMounts []rspec.Mount // Len returns the number of mounts. Used in sorting. @@ -495,6 +498,10 @@ func (s *Server) CreateContainer(ctx context.Context, req *types.CreateContainer log.Infof(ctx, description) err := s.CtrIDIndex().Delete(ctr.ID()) if err != nil { + // already deleted + if strings.Contains(err.Error(), noSuchID) { + return nil + } log.Warnf(ctx, "Couldn't delete ctr id %s from idIndex", ctr.ID()) } return err diff --git a/server/sandbox_run_linux.go b/server/sandbox_run_linux.go index d4f17983263..7cb0d9a486e 100644 --- a/server/sandbox_run_linux.go +++ b/server/sandbox_run_linux.go @@ -520,6 +520,10 @@ func (s *Server) runPodSandbox(ctx context.Context, req *types.RunPodSandboxRequ log.Infof(ctx, description) err2 := s.CtrIDIndex().Delete(sbox.ID()) if err2 != nil { + // already deleted + if strings.Contains(err2.Error(), noSuchID) { + return nil + } log.Warnf(ctx, "Could not delete ctr id %s from idIndex", sbox.ID()) } return err2