mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-05 13:11:30 +00:00
Force IPC mount to unmount on daemon shutdown/init
Instead of using `MNT_DETACH` to unmount the container's mqueue/shm mounts, force it... but only on daemon init and shutdown. This makes sure that these IPC mounts are cleaned up even when the daemon is killed. Signed-off-by: Brian Goff <cpuguy83@gmail.com> (cherry picked from commit 78bd17e805b7514505455b10f2fd90962505a3ff)
This commit is contained in:
+1
-1
@@ -333,7 +333,7 @@ func (streamConfig *streamConfig) StderrPipe() io.ReadCloser {
|
||||
func (container *Container) cleanup() {
|
||||
container.releaseNetwork()
|
||||
|
||||
if err := container.unmountIpcMounts(); err != nil {
|
||||
if err := container.unmountIpcMounts(detachMounted); err != nil {
|
||||
logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1456,7 +1456,7 @@ func (container *Container) setupIpcDirs() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) unmountIpcMounts() error {
|
||||
func (container *Container) unmountIpcMounts(unmount func(pth string) error) error {
|
||||
if container.hostConfig.IpcMode.IsContainer() || container.hostConfig.IpcMode.IsHost() {
|
||||
return nil
|
||||
}
|
||||
@@ -1469,7 +1469,7 @@ func (container *Container) unmountIpcMounts() error {
|
||||
logrus.Error(err)
|
||||
errors = append(errors, err.Error())
|
||||
} else {
|
||||
if err := detachMounted(shmPath); err != nil {
|
||||
if err := unmount(shmPath); err != nil {
|
||||
logrus.Errorf("failed to umount %s: %v", shmPath, err)
|
||||
errors = append(errors, err.Error())
|
||||
}
|
||||
@@ -1483,7 +1483,7 @@ func (container *Container) unmountIpcMounts() error {
|
||||
logrus.Error(err)
|
||||
errors = append(errors, err.Error())
|
||||
} else {
|
||||
if err := detachMounted(mqueuePath); err != nil {
|
||||
if err := unmount(mqueuePath); err != nil {
|
||||
logrus.Errorf("failed to umount %s: %v", mqueuePath, err)
|
||||
errors = append(errors, err.Error())
|
||||
}
|
||||
|
||||
@@ -183,11 +183,15 @@ func (container *Container) removeMountPoints(_ bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) setupIpcDirs() error {
|
||||
func (container *Container) unmountIpcMounts(unmount func(pth string) error) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) unmountIpcMounts() error {
|
||||
func detachMounted(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (container *Container) setupIpcDirs() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -38,6 +38,7 @@ import (
|
||||
"github.com/docker/docker/pkg/graphdb"
|
||||
"github.com/docker/docker/pkg/idtools"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
"github.com/docker/docker/pkg/namesgenerator"
|
||||
"github.com/docker/docker/pkg/nat"
|
||||
"github.com/docker/docker/pkg/parsers/filters"
|
||||
@@ -222,7 +223,7 @@ func (daemon *Daemon) Register(container *Container) error {
|
||||
}
|
||||
daemon.execDriver.Terminate(cmd)
|
||||
|
||||
if err := container.unmountIpcMounts(); err != nil {
|
||||
if err := container.unmountIpcMounts(mount.Unmount); err != nil {
|
||||
logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err)
|
||||
}
|
||||
if err := container.Unmount(); err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
)
|
||||
|
||||
// cleanupMounts umounts shm/mqueue mounts for old containers
|
||||
@@ -20,7 +21,7 @@ func (daemon *Daemon) cleanupMounts() error {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return daemon.cleanupMountsFromReader(f, detachMounted)
|
||||
return daemon.cleanupMountsFromReader(f, mount.Unmount)
|
||||
}
|
||||
|
||||
func (daemon *Daemon) cleanupMountsFromReader(reader io.Reader, unmount func(target string) error) error {
|
||||
|
||||
Reference in New Issue
Block a user