blob: 5af29248cdca51f764935e87ea7d63151f0455d1 [file] [log] [blame]
From dab7bd0c4549a6a012004326f7415770c23afde4 Mon Sep 17 00:00:00 2001
From: Brian Goff <cpuguy83@gmail.com>
Date: Wed, 9 Sep 2020 16:42:35 -0700
Subject: [PATCH] Always consume shim logs
diff --git a/runtime/v1/shim/client/client.go b/runtime/v1/shim/client/client.go
index 562ee6c..bb411c1 100644
--- a/runtime/v1/shim/client/client.go
+++ b/runtime/v1/shim/client/client.go
@@ -2,13 +2,10 @@
/*
Copyright The containerd Authors.
-
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
-
http://www.apache.org/licenses/LICENSE-2.0
-
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,6 +19,7 @@ import (
"context"
"fmt"
"io"
+ "io/ioutil"
"net"
"os"
"os/exec"
@@ -67,22 +65,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 {
diff --git a/runtime/v1/shim/service.go b/runtime/v1/shim/service.go
index 6bd6aef..2f5a8c2 100644
--- a/runtime/v1/shim/service.go
+++ b/runtime/v1/shim/service.go
@@ -514,7 +514,7 @@ func (s *Service) checkProcesses(e runc.Exit) {
}
s.mu.Unlock()
if p == nil {
- log.G(s.context).Infof("process with id:%d wasn't found", e.Pid)
+ log.G(s.context).Debugf("process with id:%d wasn't found", e.Pid)
return
}
if ip, ok := p.(*process.Init); ok {