2015-05-01 21:03:35 -04:00
|
|
|
package daemon
|
|
|
|
|
2015-09-16 14:56:26 -04:00
|
|
|
import (
|
2015-11-12 14:55:17 -05:00
|
|
|
"github.com/docker/docker/container"
|
2015-09-17 14:54:14 -04:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-09-16 14:56:26 -04:00
|
|
|
)
|
2015-05-01 21:03:35 -04:00
|
|
|
|
|
|
|
// ContainerUnpause unpauses a container
|
2015-09-29 13:51:40 -04:00
|
|
|
func (daemon *Daemon) ContainerUnpause(name string) error {
|
2015-12-11 12:39:28 -05:00
|
|
|
container, err := daemon.GetContainer(name)
|
2015-05-01 21:03:35 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2015-11-02 18:39:39 -05:00
|
|
|
if err := daemon.containerUnpause(container); err != nil {
|
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>
2016-02-03 01:29:15 -05:00
|
|
|
return err
|
2015-05-01 21:03:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2015-11-02 18:39:39 -05:00
|
|
|
|
|
|
|
// containerUnpause resumes the container execution after the container is paused.
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) containerUnpause(container *container.Container) error {
|
2015-11-02 18:39:39 -05:00
|
|
|
container.Lock()
|
|
|
|
defer container.Unlock()
|
|
|
|
|
|
|
|
// We cannot unpause the container which is not running
|
|
|
|
if !container.Running {
|
|
|
|
return derr.ErrorCodeNotRunning.WithArgs(container.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// We cannot unpause the container which is not paused
|
|
|
|
if !container.Paused {
|
|
|
|
return derr.ErrorCodeNotPaused.WithArgs(container.ID)
|
|
|
|
}
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
if err := daemon.execDriver.Unpause(container.Command); err != nil {
|
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>
2016-02-03 01:29:15 -05:00
|
|
|
return derr.ErrorCodeCantUnpause.WithArgs(container.ID, err)
|
2015-11-02 18:39:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
container.Paused = false
|
2015-11-03 12:33:13 -05:00
|
|
|
daemon.LogContainerEvent(container, "unpause")
|
2015-11-02 18:39:39 -05:00
|
|
|
return nil
|
|
|
|
}
|