From 7a7aec355ba1227d6d4fe6d69e9704dcbd365234 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 16 Aug 2024 13:42:05 +0200 Subject: [PATCH] podman mount: fix storage/libpod ctr race When we create a container we first create it in the storage then in the libpod db so there is a tiny window where it is seen as storage ctr but then by the time we mount it we see it was a libpod container. Fixes #23637 Signed-off-by: Paul Holzinger --- pkg/domain/infra/abi/containers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 9afed94b868d..091d493a84e0 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -1392,7 +1392,11 @@ func (ic *ContainerEngine) ContainerMount(ctx context.Context, nameOrIDs []strin for _, sctr := range storageCtrs { mounted, path, err := ic.Libpod.IsStorageContainerMounted(sctr.ID) if err != nil { - if errors.Is(err, types.ErrContainerUnknown) { + // ErrCtrExists means this is a libpod container, we handle that below. + // This can only happen in a narrow race because we first create the storage + // container and then the libpod container so the StorageContainers() call + // above would need to happen in that interval. + if errors.Is(err, types.ErrContainerUnknown) || errors.Is(err, define.ErrCtrExists) { continue } return nil, err