Remove redundant error message
Currently some commands including `kill`, `pause`, `restart`, `rm`, `rmi`, `stop`, `unpause`, `udpate`, `wait` will print a lot of error message on client side, with a lot of redundant messages, this commit is trying to remove the unuseful and redundant information for user. Signed-off-by: Zhang Wei <zhangwei555@huawei.com> Upstream-commit: 894266c1bbdfeb53bf278f3cb762945bac69e592 Component: engine
This commit is contained in:
@@ -30,7 +30,7 @@ func (daemon *Daemon) ContainerRm(name string, config *types.ContainerRmConfig)
|
||||
// do not fail when the removal is in progress started by other request.
|
||||
return nil
|
||||
}
|
||||
return derr.ErrorCodeRmState.WithArgs(err)
|
||||
return derr.ErrorCodeRmState.WithArgs(container.ID, err)
|
||||
}
|
||||
defer container.ResetRemovalInProgress()
|
||||
|
||||
@@ -84,10 +84,10 @@ func (daemon *Daemon) rmLink(container *container.Container, name string) error
|
||||
func (daemon *Daemon) cleanupContainer(container *container.Container, forceRemove bool) (err error) {
|
||||
if container.IsRunning() {
|
||||
if !forceRemove {
|
||||
return derr.ErrorCodeRmRunning
|
||||
return derr.ErrorCodeRmRunning.WithArgs(container.ID)
|
||||
}
|
||||
if err := daemon.Kill(container); err != nil {
|
||||
return derr.ErrorCodeRmFailed.WithArgs(err)
|
||||
return derr.ErrorCodeRmFailed.WithArgs(container.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func (daemon *Daemon) killWithSignal(container *container.Container, sig int) er
|
||||
}
|
||||
|
||||
if err := daemon.kill(container, sig); err != nil {
|
||||
return err
|
||||
return derr.ErrorCodeCantKill.WithArgs(container.ID, err)
|
||||
}
|
||||
|
||||
attributes := map[string]string{
|
||||
|
||||
@@ -13,7 +13,7 @@ func (daemon *Daemon) ContainerPause(name string) error {
|
||||
}
|
||||
|
||||
if err := daemon.containerPause(container); err != nil {
|
||||
return derr.ErrorCodePauseError.WithArgs(name, err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -36,7 +36,7 @@ func (daemon *Daemon) containerPause(container *container.Container) error {
|
||||
}
|
||||
|
||||
if err := daemon.execDriver.Pause(container.Command); err != nil {
|
||||
return err
|
||||
return derr.ErrorCodeCantPause.WithArgs(container.ID, err)
|
||||
}
|
||||
container.Paused = true
|
||||
daemon.LogContainerEvent(container, "pause")
|
||||
|
||||
@@ -20,7 +20,7 @@ func (daemon *Daemon) ContainerStop(name string, seconds int) error {
|
||||
return err
|
||||
}
|
||||
if !container.IsRunning() {
|
||||
return derr.ErrorCodeStopped
|
||||
return derr.ErrorCodeStopped.WithArgs(name)
|
||||
}
|
||||
if err := daemon.containerStop(container, seconds); err != nil {
|
||||
return derr.ErrorCodeCantStop.WithArgs(name, err)
|
||||
|
||||
@@ -13,7 +13,7 @@ func (daemon *Daemon) ContainerUnpause(name string) error {
|
||||
}
|
||||
|
||||
if err := daemon.containerUnpause(container); err != nil {
|
||||
return derr.ErrorCodeCantUnpause.WithArgs(name, err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -35,7 +35,7 @@ func (daemon *Daemon) containerUnpause(container *container.Container) error {
|
||||
}
|
||||
|
||||
if err := daemon.execDriver.Unpause(container.Command); err != nil {
|
||||
return err
|
||||
return derr.ErrorCodeCantUnpause.WithArgs(container.ID, err)
|
||||
}
|
||||
|
||||
container.Paused = false
|
||||
|
||||
@@ -3,6 +3,7 @@ package daemon
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
derr "github.com/docker/docker/errors"
|
||||
"github.com/docker/engine-api/types/container"
|
||||
)
|
||||
|
||||
@@ -44,15 +45,17 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
|
||||
}
|
||||
|
||||
if container.RemovalInProgress || container.Dead {
|
||||
return fmt.Errorf("Container is marked for removal and cannot be \"update\".")
|
||||
errMsg := fmt.Errorf("Container is marked for removal and cannot be \"update\".")
|
||||
return derr.ErrorCodeCantUpdate.WithArgs(container.ID, errMsg)
|
||||
}
|
||||
|
||||
if container.IsRunning() && hostConfig.KernelMemory != 0 {
|
||||
return fmt.Errorf("Can not update kernel memory to a running container, please stop it first.")
|
||||
errMsg := fmt.Errorf("Can not update kernel memory to a running container, please stop it first.")
|
||||
return derr.ErrorCodeCantUpdate.WithArgs(container.ID, errMsg)
|
||||
}
|
||||
|
||||
if err := container.UpdateContainer(hostConfig); err != nil {
|
||||
return err
|
||||
return derr.ErrorCodeCantUpdate.WithArgs(container.ID, err.Error())
|
||||
}
|
||||
|
||||
// If container is not running, update hostConfig struct is enough,
|
||||
@@ -61,7 +64,7 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
|
||||
// to the real world.
|
||||
if container.IsRunning() {
|
||||
if err := daemon.execDriver.Update(container.Command); err != nil {
|
||||
return err
|
||||
return derr.ErrorCodeCantUpdate.WithArgs(container.ID, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user