From 08091ba9fb1bbf34e723523779bca5d05f6b3177 Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 30 Oct 2015 19:00:01 -0400 Subject: [PATCH] Turn IPC unmount errors into warnings. And do not try to unmount empty paths. Because nobody should be woken up in the middle of the night for them. Signed-off-by: David Calavera (cherry picked from commit a54d5932e3a644317c77d59bc5aee562841d5c20) --- daemon/container.go | 4 +--- daemon/container_unix.go | 26 +++++++++++--------------- daemon/container_windows.go | 3 +-- daemon/daemon.go | 5 ++--- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/daemon/container.go b/daemon/container.go index 99c1d8447..ace100c7e 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -333,9 +333,7 @@ func (streamConfig *streamConfig) StderrPipe() io.ReadCloser { func (container *Container) cleanup() { container.releaseNetwork() - if err := container.unmountIpcMounts(detachMounted); err != nil { - logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err) - } + container.unmountIpcMounts(detachMounted) if err := container.Unmount(); err != nil { logrus.Errorf("%s: Failed to umount filesystem: %v", container.ID, err) diff --git a/daemon/container_unix.go b/daemon/container_unix.go index 0035eeb57..9b55302d7 100644 --- a/daemon/container_unix.go +++ b/daemon/container_unix.go @@ -1456,22 +1456,21 @@ func (container *Container) setupIpcDirs() error { return nil } -func (container *Container) unmountIpcMounts(unmount func(pth string) error) error { +func (container *Container) unmountIpcMounts(unmount func(pth string) error) { if container.hostConfig.IpcMode.IsContainer() || container.hostConfig.IpcMode.IsHost() { - return nil + return } - var errors []string + var warnings []string if !container.hasMountFor("/dev/shm") { shmPath, err := container.shmPath() if err != nil { logrus.Error(err) - errors = append(errors, err.Error()) - } else { + warnings = append(warnings, err.Error()) + } else if shmPath != "" { if err := unmount(shmPath); err != nil { - logrus.Errorf("failed to umount %s: %v", shmPath, err) - errors = append(errors, err.Error()) + warnings = append(warnings, fmt.Sprintf("failed to umount %s: %v", shmPath, err)) } } @@ -1481,20 +1480,17 @@ func (container *Container) unmountIpcMounts(unmount func(pth string) error) err mqueuePath, err := container.mqueuePath() if err != nil { logrus.Error(err) - errors = append(errors, err.Error()) - } else { + warnings = append(warnings, err.Error()) + } else if mqueuePath != "" { if err := unmount(mqueuePath); err != nil { - logrus.Errorf("failed to umount %s: %v", mqueuePath, err) - errors = append(errors, err.Error()) + warnings = append(warnings, fmt.Sprintf("failed to umount %s: %v", mqueuePath, err)) } } } - if len(errors) > 0 { - return fmt.Errorf("failed to cleanup ipc mounts:\n%v", strings.Join(errors, "\n")) + if len(warnings) > 0 { + logrus.Warnf("failed to cleanup ipc mounts:\n%v", strings.Join(warnings, "\n")) } - - return nil } func (container *Container) ipcMounts() []execdriver.Mount { diff --git a/daemon/container_windows.go b/daemon/container_windows.go index e97e753f5..ff33ba487 100644 --- a/daemon/container_windows.go +++ b/daemon/container_windows.go @@ -183,8 +183,7 @@ func (container *Container) removeMountPoints(_ bool) error { return nil } -func (container *Container) unmountIpcMounts(unmount func(pth string) error) error { - return nil +func (container *Container) unmountIpcMounts(unmount func(pth string) error) { } func detachMounted(path string) error { diff --git a/daemon/daemon.go b/daemon/daemon.go index cf0430b29..f394e854a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -223,9 +223,8 @@ func (daemon *Daemon) Register(container *Container) error { } daemon.execDriver.Terminate(cmd) - if err := container.unmountIpcMounts(mount.Unmount); err != nil { - logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err) - } + container.unmountIpcMounts(mount.Unmount) + if err := container.Unmount(); err != nil { logrus.Debugf("unmount error %s", err) }