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

Merge pull request #42182 from thaJeztah/fix_exec_start_err_handling

Fix error-handling in `daemon.ContainerExecStart()` and `daemon.getExecConfig()`
This commit is contained in:
Sebastiaan van Stijn 2021-04-29 21:33:19 +02:00 committed by GitHub
commit dd3275c5f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,7 +59,7 @@ func (daemon *Daemon) getExecConfig(name string) (*exec.Config, error) {
return nil, containerNotFound(name)
}
if !ctr.IsRunning() {
return nil, fmt.Errorf("Container %s is not running: %s", ctr.ID, ctr.State.String())
return nil, errNotRunning(ctr.ID)
}
if ctr.IsPaused() {
return nil, errExecPaused(ctr.ID)
@ -158,7 +158,7 @@ func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, stdin
ec, err := daemon.getExecConfig(name)
if err != nil {
return errExecNotFound(name)
return err
}
ec.Lock()
@ -176,6 +176,9 @@ func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, stdin
ec.Unlock()
c := daemon.containers.Get(ec.ContainerID)
if c == nil {
return containerNotFound(ec.ContainerID)
}
logrus.Debugf("starting exec command %s in container %s", ec.ID, c.ID)
attributes := map[string]string{
"execID": ec.ID,