Skip to content

Commit dab7bd0

Browse files
committed
Always consume shim logs
These fifos fill up if unconsumed, so always consume them. Signed-off-by: Brian Goff <[email protected]>
1 parent d4e7820 commit dab7bd0

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

runtime/v1/shim/client/client.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"context"
2323
"fmt"
2424
"io"
25+
"io/ioutil"
2526
"net"
2627
"os"
2728
"os/exec"
@@ -67,22 +68,24 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
6768
}
6869
defer f.Close()
6970

70-
var stdoutLog io.ReadWriteCloser
71-
var stderrLog io.ReadWriteCloser
72-
if debug {
73-
stdoutLog, err = v1.OpenShimStdoutLog(ctx, config.WorkDir)
74-
if err != nil {
75-
return nil, nil, errors.Wrapf(err, "failed to create stdout log")
76-
}
77-
78-
stderrLog, err = v1.OpenShimStderrLog(ctx, config.WorkDir)
79-
if err != nil {
80-
return nil, nil, errors.Wrapf(err, "failed to create stderr log")
81-
}
71+
stdoutCopy := ioutil.Discard
72+
stderrCopy := ioutil.Discard
73+
stdoutLog, err := v1.OpenShimStdoutLog(ctx, config.WorkDir)
74+
if err != nil {
75+
return nil, nil, errors.Wrapf(err, "failed to create stdout log")
76+
}
8277

83-
go io.Copy(os.Stdout, stdoutLog)
84-
go io.Copy(os.Stderr, stderrLog)
78+
stderrLog, err := v1.OpenShimStderrLog(ctx, config.WorkDir)
79+
if err != nil {
80+
return nil, nil, errors.Wrapf(err, "failed to create stderr log")
8581
}
82+
if debug {
83+
stdoutCopy = os.Stdout
84+
stderrCopy = os.Stderr
85+
}
86+
87+
go io.Copy(stdoutCopy, stdoutLog)
88+
go io.Copy(stderrCopy, stderrLog)
8689

8790
cmd, err := newCommand(binary, daemonAddress, debug, config, f, stdoutLog, stderrLog)
8891
if err != nil {

0 commit comments

Comments
 (0)