Merge pull request #16785 from cpuguy83/exec_cleanup

Cleanup some issues with exec
This commit is contained in:
Jess Frazelle 2015-10-08 12:02:03 -07:00
commit cc411c054f
4 changed files with 13 additions and 12 deletions

View file

@ -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
}
}
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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)
}
}