Catch command pipeline error.

Rather than ignoring errors in the pipeline, return an execution error
and do not proceed with the latest command in the pipeline.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: f38257308b12ecf6de7ce72895a6430d6a3dc775
Component: engine
This commit is contained in:
David Calavera
2015-12-22 15:17:15 -05:00
parent 7bdc187f53
commit 608da884be

View File

@ -191,12 +191,19 @@ func RunCommandPipelineWithOutput(cmds ...*exec.Cmd) (output string, exitCode in
}
}
var pipelineError error
defer func() {
// wait all cmds except the last to release their resources
for _, cmd := range cmds[:len(cmds)-1] {
cmd.Wait()
if err := cmd.Wait(); err != nil {
pipelineError = fmt.Errorf("command %s failed with error: %v", cmd.Path, err)
break
}
}
}()
if pipelineError != nil {
return "", 0, pipelineError
}
// wait on last cmd
return RunCommandWithOutput(cmds[len(cmds)-1])