1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix docker top a restarting container

Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
Lei Jitang 2016-02-02 21:05:01 -05:00
parent 5cdc0dfce3
commit 5566ccb7aa
3 changed files with 14 additions and 11 deletions

View file

@ -53,7 +53,7 @@ func (d *Daemon) getExecConfig(name string) (*exec.Config, error) {
return nil, derr.ErrorCodeExecPaused.WithArgs(container.ID)
}
if container.IsRestarting() {
return nil, derr.ErrorCodeExecRestarting.WithArgs(container.ID)
return nil, derr.ErrorCodeContainerRestarting.WithArgs(container.ID)
}
return ec, nil
}
@ -80,7 +80,7 @@ func (d *Daemon) getActiveContainer(name string) (*container.Container, error) {
return nil, derr.ErrorCodeExecPaused.WithArgs(name)
}
if container.IsRestarting() {
return nil, derr.ErrorCodeExecRestarting.WithArgs(name)
return nil, derr.ErrorCodeContainerRestarting.WithArgs(name)
}
return container, nil
}

View file

@ -30,6 +30,9 @@ func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.Container
return nil, derr.ErrorCodeNotRunning.WithArgs(name)
}
if container.IsRestarting() {
return nil, derr.ErrorCodeContainerRestarting.WithArgs(name)
}
pids, err := daemon.ExecutionDriver().GetPidsForContainer(container.ID)
if err != nil {
return nil, err

View file

@ -715,6 +715,15 @@ var (
HTTPStatusCode: http.StatusConflict,
})
// ErrorCodeContainerRestarting is generated when an operation was made
// on a restarting container.
ErrorCodeContainerRestarting = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "CONTAINERRESTARTING",
Message: "Container %s is restarting, wait until the container is running",
Description: "An operation was made on a restarting container",
HTTPStatusCode: http.StatusConflict,
})
// ErrorCodeNoExecID is generated when we try to get the info
// on an exec but it can't be found.
ErrorCodeNoExecID = errcode.Register(errGroup, errcode.ErrorDescriptor{
@ -733,15 +742,6 @@ var (
HTTPStatusCode: http.StatusConflict,
})
// ErrorCodeExecRestarting is generated when we try to start an exec
// but the container is restarting.
ErrorCodeExecRestarting = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "EXECRESTARTING",
Message: "Container %s is restarting, wait until the container is running",
Description: "An attempt to start an 'exec' was made, but the owning container is restarting",
HTTPStatusCode: http.StatusConflict,
})
// ErrorCodeExecRunning is generated when we try to start an exec
// but its already running.
ErrorCodeExecRunning = errcode.Register(errGroup, errcode.ErrorDescriptor{