Cleanup some issues with exec
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
parent
072ac5e7f0
commit
561005e5ca
4 changed files with 13 additions and 12 deletions
|
@ -239,14 +239,13 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
|
|||
case err := <-receiveStdout:
|
||||
if err != nil {
|
||||
logrus.Debugf("Error receiveStdout: %s", err)
|
||||
}
|
||||
if cli.isTerminalIn {
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
case <-stdinDone:
|
||||
if stdout != nil || stderr != nil {
|
||||
if err := <-receiveStdout; err != nil {
|
||||
logrus.Debugf("Error receiveStdout: %s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ func (s *router) postContainerExecStart(ctx context.Context, w http.ResponseWrit
|
|||
if execStartCheck.Detach {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(outStream, "Error running exec in container: %v\n", err)
|
||||
logrus.Errorf("Error running exec in container: %v\n", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -790,7 +790,7 @@ func (container *Container) getExecIDs() []string {
|
|||
return container.execCommands.List()
|
||||
}
|
||||
|
||||
func (container *Container) exec(ExecConfig *ExecConfig) error {
|
||||
func (container *Container) exec(ec *ExecConfig) error {
|
||||
container.Lock()
|
||||
defer container.Unlock()
|
||||
|
||||
|
@ -803,17 +803,17 @@ func (container *Container) exec(ExecConfig *ExecConfig) error {
|
|||
c.Close()
|
||||
}
|
||||
}
|
||||
close(ExecConfig.waitStart)
|
||||
close(ec.waitStart)
|
||||
return nil
|
||||
}
|
||||
|
||||
// We use a callback here instead of a goroutine and an chan for
|
||||
// synchronization purposes
|
||||
cErr := promise.Go(func() error { return container.monitorExec(ExecConfig, callback) })
|
||||
cErr := promise.Go(func() error { return container.monitorExec(ec, callback) })
|
||||
|
||||
// Exec should not return until the process is actually running
|
||||
select {
|
||||
case <-ExecConfig.waitStart:
|
||||
case <-ec.waitStart:
|
||||
case err := <-cErr:
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -251,10 +251,9 @@ func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io.
|
|||
// the exitStatus) even after the cmd is done running.
|
||||
|
||||
go func() {
|
||||
if err := container.exec(ec); err != nil {
|
||||
execErr <- derr.ErrorCodeExecCantRun.WithArgs(ec.ID, container.ID, err)
|
||||
}
|
||||
execErr <- container.exec(ec)
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-attachErr:
|
||||
if err != nil {
|
||||
|
@ -262,6 +261,9 @@ func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io.
|
|||
}
|
||||
return nil
|
||||
case err := <-execErr:
|
||||
if aErr := <-attachErr; aErr != nil && err == nil {
|
||||
return derr.ErrorCodeExecAttach.WithArgs(aErr)
|
||||
}
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -270,7 +272,7 @@ func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io.
|
|||
if !container.IsRunning() {
|
||||
return derr.ErrorCodeExecContainerStopped
|
||||
}
|
||||
return err
|
||||
return derr.ErrorCodeExecCantRun.WithArgs(ec.ID, container.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue