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{