Skip to content

Commit

Permalink
container: always check if mountpoint is mounted
Browse files Browse the repository at this point in the history
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: containers#17042

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Oct 8, 2023
1 parent c343f7a commit 0b21759
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,11 @@ 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
if mounted, err := mount.Mounted(c.state.Mountpoint); err != nil {
return "", fmt.Errorf("unable to determine if %q is mounted: %w", c.state.Mountpoint, err)
} else if mounted {
return c.state.Mountpoint, nil
}
}

if !c.config.NoShm {
Expand Down

0 comments on commit 0b21759

Please sign in to comment.