ContainerExecStart(): don't wrap getExecConfig() errors, and prevent panic
daemon.getExecConfig() already returns typed errors; by wrapping those errors we may loose the actual reason for failures. Changing the error-type was originally added in2d43d93410
, but I think it was not intentional to ignore already-typed errors. It was later refactored ina793564b25
, which added helper functions to create these errors, but kept the same behavior. Also adds error-handling to prevent a panic in situations where (although unlikely) `daemon.containers.Get()` would not return a container. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6eb5720233
commit
a432eb4b3a
1 changed files with 4 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue