summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2020-01-14 15:41:38 +0100
committerValentin Rothberg <rothberg@redhat.com>2020-01-15 17:08:22 +0100
commit88372c2c21b653131f993825484bf9a5ea509bdf (patch)
treef5af806d59a18f62aadf69603d5f23aaee9546c2 /pkg
parent63d8ba64e4fd1ed1bef910b313029ca6535f43cf (diff)
downloadpodman-88372c2c21b653131f993825484bf9a5ea509bdf.tar.gz
podman-88372c2c21b653131f993825484bf9a5ea509bdf.tar.bz2
podman-88372c2c21b653131f993825484bf9a5ea509bdf.zip
top: use a separate pipe for the error stream
Let's not mix apples and oranges and give stderr a dedicated pipe. This way, we don't return conmon log messages if run in debug mode. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/adapter/containers.go32
1 files changed, 27 insertions, 5 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index df9f13944..a257ef4f4 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -951,17 +951,31 @@ func (r *LocalRuntime) execPS(c *libpod.Container, args []string) ([]string, err
defer wPipe.Close()
defer rPipe.Close()
+ rErrPipe, wErrPipe, err := os.Pipe()
+ if err != nil {
+ return nil, err
+ }
+ defer wErrPipe.Close()
+ defer rErrPipe.Close()
+
streams := new(libpod.AttachStreams)
streams.OutputStream = wPipe
- streams.ErrorStream = wPipe
+ streams.ErrorStream = wErrPipe
streams.AttachOutput = true
streams.AttachError = true
- psOutput := []string{}
+ stdout := []string{}
go func() {
scanner := bufio.NewScanner(rPipe)
for scanner.Scan() {
- psOutput = append(psOutput, scanner.Text())
+ stdout = append(stdout, scanner.Text())
+ }
+ }()
+ stderr := []string{}
+ go func() {
+ scanner := bufio.NewScanner(rErrPipe)
+ for scanner.Scan() {
+ stderr = append(stderr, scanner.Text())
}
}()
@@ -970,10 +984,18 @@ func (r *LocalRuntime) execPS(c *libpod.Container, args []string) ([]string, err
if err != nil {
return nil, err
} else if ec != 0 {
- return nil, errors.Errorf("Runtime failed with exit status: %d and output: %s", ec, strings.Join(psOutput, " "))
+ return nil, errors.Errorf("Runtime failed with exit status: %d and output: %s", ec, strings.Join(stderr, " "))
+ }
+
+ if logrus.GetLevel() >= logrus.DebugLevel {
+ // If we're running in debug mode or higher, we might want to have a
+ // look at stderr which includes debug logs from conmon.
+ for _, log := range stderr {
+ logrus.Debugf("%s", log)
+ }
}
- return psOutput, nil
+ return stdout, nil
}
// ExecContainer executes a command in the container