Handle errors on attach properly

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-06-12 07:49:28 -04:00
parent b89729778c
commit b2792dd76a

View File

@ -445,10 +445,15 @@ func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input,
}() }()
// Wait for the attach to actually happen before starting // Wait for the attach to actually happen before starting
// the container. // the container.
<-attachReady select {
if err := containers.Start(ic.ClientCxt, name, detachKeys); err != nil { case <-attachReady:
if err := containers.Start(ic.ClientCxt, name, detachKeys); err != nil {
return err
}
case err := <-attachErr:
return err return err
} }
// If attachReady happens first, wait for containers.Attach to complete
return <-attachErr return <-attachErr
} }