diff --git a/daemon/container_operations_unix.go b/daemon/container_operations_unix.go index 40240d427a..c19a111561 100644 --- a/daemon/container_operations_unix.go +++ b/daemon/container_operations_unix.go @@ -59,13 +59,11 @@ func (daemon *Daemon) setupLinkedContainers(container *container.Container) ([]s return env, nil } -func (daemon *Daemon) getIpcContainer(id string) (*container.Container, error) { - errMsg := "can't join IPC of container " + id - +func (daemon *Daemon) getIPCContainer(id string) (*container.Container, error) { // Check if the container exists, is running, and not restarting ctr, err := daemon.GetContainer(id) if err != nil { - return nil, errdefs.InvalidParameter(errors.Wrap(err, errMsg)) + return nil, errdefs.InvalidParameter(err) } if !ctr.IsRunning() { return nil, errNotRunning(id) @@ -77,10 +75,10 @@ func (daemon *Daemon) getIpcContainer(id string) (*container.Container, error) { // Check the container ipc is shareable if st, err := os.Stat(ctr.ShmPath); err != nil || !st.IsDir() { if err == nil || os.IsNotExist(err) { - return nil, errdefs.InvalidParameter(errors.New(errMsg + ": non-shareable IPC (hint: use IpcMode:shareable for the donor container)")) + return nil, errdefs.InvalidParameter(errors.New("container " + id + ": non-shareable IPC (hint: use IpcMode:shareable for the donor container)")) } // stat() failed? - return nil, errdefs.System(errors.Wrap(err, errMsg+": unexpected error from stat "+ctr.ShmPath)) + return nil, errdefs.System(errors.Wrap(err, "container "+id)) } return ctr, nil @@ -101,14 +99,14 @@ func (daemon *Daemon) getPIDContainer(id string) (*container.Container, error) { return ctr, nil } -func (daemon *Daemon) setupIpcDirs(c *container.Container) error { +func (daemon *Daemon) setupIPCDirs(c *container.Container) error { ipcMode := c.HostConfig.IpcMode switch { case ipcMode.IsContainer(): - ic, err := daemon.getIpcContainer(ipcMode.Container()) + ic, err := daemon.getIPCContainer(ipcMode.Container()) if err != nil { - return err + return errors.Wrapf(err, "failed to join IPC namespace") } c.ShmPath = ic.ShmPath diff --git a/daemon/oci_linux.go b/daemon/oci_linux.go index 68d9423fa1..3f48bda80d 100644 --- a/daemon/oci_linux.go +++ b/daemon/oci_linux.go @@ -292,9 +292,9 @@ func WithNamespaces(daemon *Daemon, c *container.Container) coci.SpecOpts { } switch { case ipcMode.IsContainer(): - ic, err := daemon.getIpcContainer(ipcMode.Container()) + ic, err := daemon.getIPCContainer(ipcMode.Container()) if err != nil { - return errors.Wrapf(err, "invalid IPC mode: %v", ipcMode) + return errors.Wrap(err, "failed to join IPC namespace") } setNamespace(s, specs.LinuxNamespace{ Type: specs.IPCNamespace, @@ -526,7 +526,7 @@ func withMounts(daemon *Daemon, daemonCfg *configStore, c *container.Container) return err } - if err := daemon.setupIpcDirs(c); err != nil { + if err := daemon.setupIPCDirs(c); err != nil { return err }