Skip to content

Commit

Permalink
Always consume shim logs
Browse files Browse the repository at this point in the history
These fifos fill up if unconsumed, so always consume them.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit dab7bd0)
Signed-off-by: Derek McGowan <derek@mcg.dev>
  • Loading branch information
cpuguy83 authored and dmcgowan committed Sep 11, 2020
1 parent ea29a60 commit 42f3871
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions runtime/v1/shim/client/client.go
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"os"
"os/exec"
Expand Down Expand Up @@ -67,22 +68,24 @@ func WithStart(binary, address, daemonAddress, cgroup string, debug bool, exitHa
}
defer f.Close()

var stdoutLog io.ReadWriteCloser
var stderrLog io.ReadWriteCloser
if debug {
stdoutLog, err = v1.OpenShimStdoutLog(ctx, config.WorkDir)
if err != nil {
return nil, nil, errors.Wrapf(err, "failed to create stdout log")
}

stderrLog, err = v1.OpenShimStderrLog(ctx, config.WorkDir)
if err != nil {
return nil, nil, errors.Wrapf(err, "failed to create stderr log")
}
stdoutCopy := ioutil.Discard
stderrCopy := ioutil.Discard
stdoutLog, err := v1.OpenShimStdoutLog(ctx, config.WorkDir)
if err != nil {
return nil, nil, errors.Wrapf(err, "failed to create stdout log")
}

go io.Copy(os.Stdout, stdoutLog)
go io.Copy(os.Stderr, stderrLog)
stderrLog, err := v1.OpenShimStderrLog(ctx, config.WorkDir)
if err != nil {
return nil, nil, errors.Wrapf(err, "failed to create stderr log")
}
if debug {
stdoutCopy = os.Stdout
stderrCopy = os.Stderr
}

go io.Copy(stdoutCopy, stdoutLog)
go io.Copy(stderrCopy, stderrLog)

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

0 comments on commit 42f3871

Please sign in to comment.