Skip to content

Commit

Permalink
containerd: Backport shim logs fixes
Browse files Browse the repository at this point in the history
Backort the patch from
containerd/containerd@42f3871
which ensures that fifos are consumed and do not fill up.
  • Loading branch information
zmrow committed Nov 16, 2020
1 parent 2052a2b commit 9e18bc7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
65 changes: 65 additions & 0 deletions packages/containerd/5001-Always-consume-shim-logs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
From 42f3871864a49f492d7a3f014ea3930c5f20b14d 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

These fifos fill up if unconsumed, so always consume them.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit dab7bd0c4549a6a012004326f7415770c23afde4)
Signed-off-by: Derek McGowan <derek@mcg.dev>
---
runtime/v1/shim/client/client.go | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/runtime/v1/shim/client/client.go b/runtime/v1/shim/client/client.go
index 562ee6ca48..9653454afc 100644
--- a/runtime/v1/shim/client/client.go
+++ b/runtime/v1/shim/client/client.go
@@ -22,6 +22,7 @@ import (
"context"
"fmt"
"io"
+ "io/ioutil"
"net"
"os"
"os/exec"
@@ -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 {
3 changes: 3 additions & 0 deletions packages/containerd/containerd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Patch3001: 3001-cri-set-default-RLIMIT_NOFILE.patch
Patch4001: 4001-Exit-signal-forward-if-process-not-found.patch
Patch4002: 4002-Ignore-SIGURG-signals-in-signal-forwarder.patch

# Upstream patch; can drop when we move to 1.4.1
Patch5001: 5001-Always-consume-shim-logs.patch

BuildRequires: git
BuildRequires: %{_cross_os}glibc-devel
BuildRequires: %{_cross_os}libseccomp-devel
Expand Down

0 comments on commit 9e18bc7

Please sign in to comment.