From 8ac2aa79382e6852657e633642530265d3a4d952 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 7 Oct 2023 23:38:12 +0200 Subject: [PATCH] container: always check if mountpoint is mounted when running as a service, the c.state.Mounted flag could get out of sync if the container is cleaned up through the cleanup process. To avoid this, always check if the mountpoint is really present before skipping the mount. [NO NEW TESTS NEEDED] Closes: https://github.com/containers/podman/issues/17042 Signed-off-by: Giuseppe Scrivano --- libpod/container_internal.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 4098296b5f..6e8306a240 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1539,7 +1539,13 @@ func (c *Container) mountStorage() (_ string, deferredErr error) { var err error // Container already mounted, nothing to do if c.state.Mounted { - return c.state.Mountpoint, nil + mounted := true + if c.ensureState(define.ContainerStateExited) { + mounted, _ = mount.Mounted(c.state.Mountpoint) + } + if mounted { + return c.state.Mountpoint, nil + } } if !c.config.NoShm {