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 <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2023-10-07 23:38:12 +02:00
parent 9beb3a9720
commit 8ac2aa7938
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
1 changed files with 7 additions and 1 deletions

View File

@ -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 {