From 14d8b5d3913c2a6b320c564d6fc11c1d90769a97 Mon Sep 17 00:00:00 2001 From: Tristan Colgate-McFarlane Date: Mon, 3 Feb 2020 16:20:29 +0000 Subject: [PATCH] fix: archiveLogs needs to copy stderr (#2136) --- workflow/executor/docker/docker.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/workflow/executor/docker/docker.go b/workflow/executor/docker/docker.go index 59dc3cf8d04c..098d3ef4e0d0 100644 --- a/workflow/executor/docker/docker.go +++ b/workflow/executor/docker/docker.go @@ -5,6 +5,7 @@ import ( "compress/gzip" "fmt" "io" + "io/ioutil" "os" "os/exec" "time" @@ -72,13 +73,20 @@ func (d *DockerExecutor) CopyFile(containerID string, sourcePath string, destPat func (d *DockerExecutor) GetOutputStream(containerID string, combinedOutput bool) (io.ReadCloser, error) { cmd := exec.Command("docker", "logs", containerID) log.Info(cmd.Args) - if combinedOutput { - cmd.Stderr = cmd.Stdout - } + reader, err := cmd.StdoutPipe() if err != nil { return nil, errors.InternalWrapError(err) } + + if combinedOutput { + stderr, err := cmd.StderrPipe() + if err != nil { + return nil, errors.InternalWrapError(err) + } + reader = ioutil.NopCloser(io.MultiReader(reader, stderr)) + } + err = cmd.Start() if err != nil { return nil, errors.InternalWrapError(err)