From 20927ffbe7cf1f6bdc2f7eb17db2a443abacf4c0 Mon Sep 17 00:00:00 2001 From: Lei Jitang Date: Sun, 31 May 2015 03:32:29 +0800 Subject: [PATCH] Correct the error message of pause and unpause non-running container Signed-off-by: Lei Jitang --- daemon/container.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/daemon/container.go b/daemon/container.go index 713682a986..18726ca5d0 100644 --- a/daemon/container.go +++ b/daemon/container.go @@ -396,16 +396,16 @@ func (container *Container) Pause() error { container.Lock() defer container.Unlock() + // We cannot Pause the container which is not running + if !container.Running { + return fmt.Errorf("Container %s is not running, cannot pause a non-running container", container.ID) + } + // We cannot Pause the container which is already paused if container.Paused { return fmt.Errorf("Container %s is already paused", container.ID) } - // We cannot Pause the container which is not running - if !container.Running { - return fmt.Errorf("Container %s is not running", container.ID) - } - if err := container.daemon.execDriver.Pause(container.command); err != nil { return err } @@ -418,14 +418,14 @@ func (container *Container) Unpause() error { container.Lock() defer container.Unlock() - // We cannot unpause the container which is not paused - if !container.Paused { - return fmt.Errorf("Container %s is not paused, so what", container.ID) - } - // We cannot unpause the container which is not running if !container.Running { - return fmt.Errorf("Container %s is not running", container.ID) + return fmt.Errorf("Container %s is not running, cannot unpause a non-running container", container.ID) + } + + // We cannot unpause the container which is not paused + if !container.Paused { + return fmt.Errorf("Container %s is not paused", container.ID) } if err := container.daemon.execDriver.Unpause(container.command); err != nil {