Signed-off-by: Brian Goff <cpuguy83@gmail.com>
| ... | ... |
@@ -239,14 +239,13 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea |
| 239 | 239 |
case err := <-receiveStdout: |
| 240 | 240 |
if err != nil {
|
| 241 | 241 |
logrus.Debugf("Error receiveStdout: %s", err)
|
| 242 |
- } |
|
| 243 |
- if cli.isTerminalIn {
|
|
| 244 |
- return nil |
|
| 242 |
+ return err |
|
| 245 | 243 |
} |
| 246 | 244 |
case <-stdinDone: |
| 247 | 245 |
if stdout != nil || stderr != nil {
|
| 248 | 246 |
if err := <-receiveStdout; err != nil {
|
| 249 | 247 |
logrus.Debugf("Error receiveStdout: %s", err)
|
| 248 |
+ return err |
|
| 250 | 249 |
} |
| 251 | 250 |
} |
| 252 | 251 |
} |
| ... | ... |
@@ -109,7 +109,7 @@ func (s *router) postContainerExecStart(ctx context.Context, w http.ResponseWrit |
| 109 | 109 |
if execStartCheck.Detach {
|
| 110 | 110 |
return err |
| 111 | 111 |
} |
| 112 |
- fmt.Fprintf(outStream, "Error running exec in container: %v\n", err) |
|
| 112 |
+ logrus.Errorf("Error running exec in container: %v\n", err)
|
|
| 113 | 113 |
} |
| 114 | 114 |
return nil |
| 115 | 115 |
} |
| ... | ... |
@@ -790,7 +790,7 @@ func (container *Container) getExecIDs() []string {
|
| 790 | 790 |
return container.execCommands.List() |
| 791 | 791 |
} |
| 792 | 792 |
|
| 793 |
-func (container *Container) exec(ExecConfig *ExecConfig) error {
|
|
| 793 |
+func (container *Container) exec(ec *ExecConfig) error {
|
|
| 794 | 794 |
container.Lock() |
| 795 | 795 |
defer container.Unlock() |
| 796 | 796 |
|
| ... | ... |
@@ -803,17 +803,17 @@ func (container *Container) exec(ExecConfig *ExecConfig) error {
|
| 803 | 803 |
c.Close() |
| 804 | 804 |
} |
| 805 | 805 |
} |
| 806 |
- close(ExecConfig.waitStart) |
|
| 806 |
+ close(ec.waitStart) |
|
| 807 | 807 |
return nil |
| 808 | 808 |
} |
| 809 | 809 |
|
| 810 | 810 |
// We use a callback here instead of a goroutine and an chan for |
| 811 | 811 |
// synchronization purposes |
| 812 |
- cErr := promise.Go(func() error { return container.monitorExec(ExecConfig, callback) })
|
|
| 812 |
+ cErr := promise.Go(func() error { return container.monitorExec(ec, callback) })
|
|
| 813 | 813 |
|
| 814 | 814 |
// Exec should not return until the process is actually running |
| 815 | 815 |
select {
|
| 816 |
- case <-ExecConfig.waitStart: |
|
| 816 |
+ case <-ec.waitStart: |
|
| 817 | 817 |
case err := <-cErr: |
| 818 | 818 |
return err |
| 819 | 819 |
} |
| ... | ... |
@@ -251,10 +251,9 @@ func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io. |
| 251 | 251 |
// the exitStatus) even after the cmd is done running. |
| 252 | 252 |
|
| 253 | 253 |
go func() {
|
| 254 |
- if err := container.exec(ec); err != nil {
|
|
| 255 |
- execErr <- derr.ErrorCodeExecCantRun.WithArgs(ec.ID, container.ID, err) |
|
| 256 |
- } |
|
| 254 |
+ execErr <- container.exec(ec) |
|
| 257 | 255 |
}() |
| 256 |
+ |
|
| 258 | 257 |
select {
|
| 259 | 258 |
case err := <-attachErr: |
| 260 | 259 |
if err != nil {
|
| ... | ... |
@@ -262,6 +261,9 @@ func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io. |
| 262 | 262 |
} |
| 263 | 263 |
return nil |
| 264 | 264 |
case err := <-execErr: |
| 265 |
+ if aErr := <-attachErr; aErr != nil && err == nil {
|
|
| 266 |
+ return derr.ErrorCodeExecAttach.WithArgs(aErr) |
|
| 267 |
+ } |
|
| 265 | 268 |
if err == nil {
|
| 266 | 269 |
return nil |
| 267 | 270 |
} |
| ... | ... |
@@ -270,7 +272,7 @@ func (d *Daemon) ContainerExecStart(name string, stdin io.ReadCloser, stdout io. |
| 270 | 270 |
if !container.IsRunning() {
|
| 271 | 271 |
return derr.ErrorCodeExecContainerStopped |
| 272 | 272 |
} |
| 273 |
- return err |
|
| 273 |
+ return derr.ErrorCodeExecCantRun.WithArgs(ec.ID, container.ID, err) |
|
| 274 | 274 |
} |
| 275 | 275 |
} |
| 276 | 276 |
|