Use named pipes for shim logs
Relating to issue [#2606](https://github.com/containerd/containerd/issues/2606) Co-authored-by: Oliver Stenbom <ostenbom@pivotal.io> Co-authored-by: Georgi Sabev <georgethebeatle@gmail.com> Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Co-authored-by: Danail Branekov <danailster@gmail.com> Signed-off-by: Oliver Stenbom <ostenbom@pivotal.io> Signed-off-by: Georgi Sabev <georgethebeatle@gmail.com> Signed-off-by: Giuseppe Capizzi <gcapizzi@pivotal.io> Signed-off-by: Danail Branekov <danailster@gmail.com>
This commit is contained in:
@@ -21,6 +21,7 @@ package linux
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -40,6 +41,7 @@ import (
|
||||
"github.com/containerd/containerd/plugin"
|
||||
"github.com/containerd/containerd/runtime"
|
||||
"github.com/containerd/containerd/runtime/linux/runctypes"
|
||||
"github.com/containerd/containerd/runtime/v1"
|
||||
"github.com/containerd/containerd/runtime/v1/linux/proc"
|
||||
shim "github.com/containerd/containerd/runtime/v1/shim/v1"
|
||||
runc "github.com/containerd/go-runc"
|
||||
@@ -341,6 +343,30 @@ func (r *Runtime) loadTasks(ctx context.Context, ns string) ([]*Task, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
logDirPath := filepath.Join(r.root, ns, id)
|
||||
|
||||
shimStdoutLog, err := v1.OpenShimStdoutLog(ctx, logDirPath)
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).WithFields(logrus.Fields{
|
||||
"id": id,
|
||||
"namespace": ns,
|
||||
"logDirPath": logDirPath,
|
||||
}).Error("opening shim stdout log pipe")
|
||||
continue
|
||||
}
|
||||
go io.Copy(os.Stdout, shimStdoutLog)
|
||||
|
||||
shimStderrLog, err := v1.OpenShimStderrLog(ctx, logDirPath)
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).WithFields(logrus.Fields{
|
||||
"id": id,
|
||||
"namespace": ns,
|
||||
"logDirPath": logDirPath,
|
||||
}).Error("opening shim stderr log pipe")
|
||||
continue
|
||||
}
|
||||
go io.Copy(os.Stderr, shimStderrLog)
|
||||
|
||||
t, err := newTask(id, ns, pid, s, r.events, r.tasks, bundle)
|
||||
if err != nil {
|
||||
log.G(ctx).WithError(err).Error("loading task type")
|
||||
|
Reference in New Issue
Block a user