mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Change verbose builder out back to attach
This is sort of "revert" of #8415. There is some problems with using logs: * Non-live progressbars * Races when you can try to get logs before it was written(there was occasional errors in tests) Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
7cc9858223
commit
1095d5e5e4
3 changed files with 10 additions and 13 deletions
|
@ -545,21 +545,18 @@ func (b *Builder) create() (*daemon.Container, error) {
|
|||
}
|
||||
|
||||
func (b *Builder) run(c *daemon.Container) error {
|
||||
var errCh chan error
|
||||
if b.Verbose {
|
||||
errCh = b.Daemon.Attach(&c.StreamConfig, c.Config.OpenStdin, c.Config.StdinOnce, c.Config.Tty, nil, b.OutStream, b.ErrStream)
|
||||
}
|
||||
|
||||
//start the container
|
||||
if err := c.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if b.Verbose {
|
||||
logsJob := b.Engine.Job("logs", c.ID)
|
||||
logsJob.Setenv("follow", "1")
|
||||
logsJob.Setenv("stdout", "1")
|
||||
logsJob.Setenv("stderr", "1")
|
||||
logsJob.Stdout.Add(b.OutStream)
|
||||
logsJob.Stderr.Set(b.ErrStream)
|
||||
if err := logsJob.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := <-errCh; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Wait for it to finish
|
||||
|
|
|
@ -101,7 +101,7 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status {
|
|||
cStderr = job.Stderr
|
||||
}
|
||||
|
||||
<-daemon.attach(&container.StreamConfig, container.Config.OpenStdin, container.Config.StdinOnce, container.Config.Tty, cStdin, cStdout, cStderr)
|
||||
<-daemon.Attach(&container.StreamConfig, container.Config.OpenStdin, container.Config.StdinOnce, container.Config.Tty, cStdin, cStdout, cStderr)
|
||||
// If we are in stdinonce mode, wait for the process to end
|
||||
// otherwise, simply return
|
||||
if container.Config.StdinOnce && !container.Config.Tty {
|
||||
|
@ -111,7 +111,7 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status {
|
|||
return engine.StatusOK
|
||||
}
|
||||
|
||||
func (daemon *Daemon) attach(streamConfig *StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) chan error {
|
||||
func (daemon *Daemon) Attach(streamConfig *StreamConfig, openStdin, stdinOnce, tty bool, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) chan error {
|
||||
var (
|
||||
cStdout, cStderr io.ReadCloser
|
||||
cStdin io.WriteCloser
|
||||
|
|
|
@ -219,7 +219,7 @@ func (d *Daemon) ContainerExecStart(job *engine.Job) engine.Status {
|
|||
execConfig.StreamConfig.stdinPipe = ioutils.NopWriteCloser(ioutil.Discard) // Silently drop stdin
|
||||
}
|
||||
|
||||
attachErr := d.attach(&execConfig.StreamConfig, execConfig.OpenStdin, true, execConfig.ProcessConfig.Tty, cStdin, cStdout, cStderr)
|
||||
attachErr := d.Attach(&execConfig.StreamConfig, execConfig.OpenStdin, true, execConfig.ProcessConfig.Tty, cStdin, cStdout, cStderr)
|
||||
|
||||
execErr := make(chan error)
|
||||
|
||||
|
|
Loading…
Reference in a new issue