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 <david.calavera@gmail.com>
This commit is contained in:
David Calavera 2015-10-30 19:00:01 -04:00
parent 0c991f3d68
commit a54d5932e3
4 changed files with 15 additions and 23 deletions

View File

@ -341,9 +341,7 @@ func (streamConfig *streamConfig) StderrPipe() io.ReadCloser {
func (container *Container) cleanup() { func (container *Container) cleanup() {
container.releaseNetwork() container.releaseNetwork()
if err := container.unmountIpcMounts(detachMounted); err != nil { container.unmountIpcMounts(detachMounted)
logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err)
}
container.conditionalUnmountOnCleanup() container.conditionalUnmountOnCleanup()

View File

@ -1361,22 +1361,21 @@ func (container *Container) setupIpcDirs() error {
return nil 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() { if container.hostConfig.IpcMode.IsContainer() || container.hostConfig.IpcMode.IsHost() {
return nil return
} }
var errors []string var warnings []string
if !container.hasMountFor("/dev/shm") { if !container.hasMountFor("/dev/shm") {
shmPath, err := container.shmPath() shmPath, err := container.shmPath()
if err != nil { if err != nil {
logrus.Error(err) logrus.Error(err)
errors = append(errors, err.Error()) warnings = append(warnings, err.Error())
} else { } else if shmPath != "" {
if err := unmount(shmPath); err != nil { if err := unmount(shmPath); err != nil {
logrus.Errorf("failed to umount %s: %v", shmPath, err) warnings = append(warnings, fmt.Sprintf("failed to umount %s: %v", shmPath, err))
errors = append(errors, err.Error())
} }
} }
@ -1386,20 +1385,17 @@ func (container *Container) unmountIpcMounts(unmount func(pth string) error) err
mqueuePath, err := container.mqueuePath() mqueuePath, err := container.mqueuePath()
if err != nil { if err != nil {
logrus.Error(err) logrus.Error(err)
errors = append(errors, err.Error()) warnings = append(warnings, err.Error())
} else { } else if mqueuePath != "" {
if err := unmount(mqueuePath); err != nil { if err := unmount(mqueuePath); err != nil {
logrus.Errorf("failed to umount %s: %v", mqueuePath, err) warnings = append(warnings, fmt.Sprintf("failed to umount %s: %v", mqueuePath, err))
errors = append(errors, err.Error())
} }
} }
} }
if len(errors) > 0 { if len(warnings) > 0 {
return fmt.Errorf("failed to cleanup ipc mounts:\n%v", strings.Join(errors, "\n")) logrus.Warnf("failed to cleanup ipc mounts:\n%v", strings.Join(warnings, "\n"))
} }
return nil
} }
func (container *Container) ipcMounts() []execdriver.Mount { func (container *Container) ipcMounts() []execdriver.Mount {

View File

@ -177,8 +177,7 @@ func (container *Container) setupIpcDirs() error {
return nil return nil
} }
func (container *Container) unmountIpcMounts(unmount func(pth string) error) error { func (container *Container) unmountIpcMounts(unmount func(pth string) error) {
return nil
} }
func detachMounted(path string) error { func detachMounted(path string) error {

View File

@ -226,9 +226,8 @@ func (daemon *Daemon) Register(container *Container) error {
} }
daemon.execDriver.Terminate(cmd) daemon.execDriver.Terminate(cmd)
if err := container.unmountIpcMounts(mount.Unmount); err != nil { container.unmountIpcMounts(mount.Unmount)
logrus.Errorf("%s: Failed to umount ipc filesystems: %v", container.ID, err)
}
if err := container.Unmount(); err != nil { if err := container.Unmount(); err != nil {
logrus.Debugf("unmount error %s", err) logrus.Debugf("unmount error %s", err)
} }