aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorAditya Rajan <arajan@redhat.com>2021-10-18 15:47:55 +0530
committerAditya Rajan <arajan@redhat.com>2021-10-18 19:01:55 +0530
commitd0f7b99c6dfb8dcbdc4a36e765cc8eb7fcde4798 (patch)
tree30452575f0500c8370ce6a5ed16f845d7f9a36e4 /libpod/container_internal.go
parent0144f46ac5067196019225430847691502d74da7 (diff)
downloadpodman-d0f7b99c6dfb8dcbdc4a36e765cc8eb7fcde4798.tar.gz
podman-d0f7b99c6dfb8dcbdc4a36e765cc8eb7fcde4798.tar.bz2
podman-d0f7b99c6dfb8dcbdc4a36e765cc8eb7fcde4798.zip
rootfs-overlay: fix overlaybase path for cleanups
Following commit ensures not dandling mounts are left behind when we are creating an overlay on top of external rootfs. Co-authored-by: Valentin Rothberg <rothberg@redhat.com> Signed-off-by: Aditya Rajan <arajan@redhat.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 3f9738411..4e8074840 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1690,9 +1690,23 @@ func (c *Container) cleanupStorage() error {
var cleanupErr error
+ markUnmounted := func() {
+ c.state.Mountpoint = ""
+ c.state.Mounted = false
+
+ if c.valid {
+ if err := c.save(); err != nil {
+ if cleanupErr != nil {
+ logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr)
+ }
+ cleanupErr = err
+ }
+ }
+ }
+
// umount rootfs overlay if it was created
if c.config.RootfsOverlay {
- overlayBasePath := c.runtime.store.GraphRoot()
+ overlayBasePath := filepath.Dir(c.config.StaticDir)
overlayBasePath = filepath.Join(overlayBasePath, "rootfs")
if err := overlay.Unmount(overlayBasePath); err != nil {
// If the container can't remove content report the error
@@ -1717,6 +1731,7 @@ func (c *Container) cleanupStorage() error {
}
if c.config.Rootfs != "" {
+ markUnmounted()
return cleanupErr
}
@@ -1761,17 +1776,7 @@ func (c *Container) cleanupStorage() error {
}
}
- c.state.Mountpoint = ""
- c.state.Mounted = false
-
- if c.valid {
- if err := c.save(); err != nil {
- if cleanupErr != nil {
- logrus.Errorf("Unmounting container %s: %v", c.ID(), cleanupErr)
- }
- cleanupErr = err
- }
- }
+ markUnmounted()
return cleanupErr
}