From 4ad5f91de7a35763560a37b0721e571ecdb02889 Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Tue, 16 Apr 2019 21:14:35 +0800 Subject: [PATCH] ctrd: support to show shim log Signed-off-by: Wei Fu --- ctrd/supervisord/config.go | 10 +++++++++- ctrd/supervisord/option.go | 18 +++++++++++++++++- daemon/daemon.go | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ctrd/supervisord/config.go b/ctrd/supervisord/config.go index 63801e8e3..15a427976 100644 --- a/ctrd/supervisord/config.go +++ b/ctrd/supervisord/config.go @@ -18,7 +18,7 @@ type Config struct { // Metrics and monitoring settings Metrics MetricsConfig `toml:"metrics"` // Plugins provides plugin specific configuration for the initialization of a plugin - Plugins map[string]toml.Primitive `toml:"plugins"` + Plugins map[string]interface{} `toml:"plugins"` // OOMScore adjust the containerd's oom score OOMScore int `toml:"oom_score"` // Cgroup specifies cgroup information for the containerd daemon process @@ -51,3 +51,11 @@ type MetricsConfig struct { type CgroupConfig struct { Path string `toml:"path"` } + +// V1RuntimeConfig options for the runtime +// +// NOTE: don't add other thing here because default config +// will be merged with this in containerd side. +type V1RuntimeConfig struct { + ShimDebug bool `toml:"shim_debug"` +} diff --git a/ctrd/supervisord/option.go b/ctrd/supervisord/option.go index 2af0628d0..1b42aa4c3 100644 --- a/ctrd/supervisord/option.go +++ b/ctrd/supervisord/option.go @@ -1,6 +1,8 @@ package supervisord -import "fmt" +import ( + "fmt" +) // WithGRPCAddress sets the containerd address. func WithGRPCAddress(addr string) Opt { @@ -41,3 +43,17 @@ func WithContainerdBinary(nameOrPath string) Opt { return nil } } + +// WithV1RuntimeShimDebug shows shim log in stdout. +func WithV1RuntimeShimDebug() Opt { + return func(d *Daemon) error { + var v1RuntimeCfg = V1RuntimeConfig{ShimDebug: true} + + // FIXME: plugin name is hard code + if d.cfg.Plugins == nil { + d.cfg.Plugins = map[string]interface{}{} + } + d.cfg.Plugins["linux"] = v1RuntimeCfg + return nil + } +} diff --git a/daemon/daemon.go b/daemon/daemon.go index 8a09765e2..e079ecd1a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -80,6 +80,7 @@ func NewDaemon(cfg *config.Config) *Daemon { if cfg.Debug { ctrdDaemonOpts = append(ctrdDaemonOpts, supervisord.WithLogLevel("debug")) + ctrdDaemonOpts = append(ctrdDaemonOpts, supervisord.WithV1RuntimeShimDebug()) } ctrdDaemon, err := supervisord.Start(context.TODO(),