Skip to content

Commit

Permalink
ctrd: support to show shim log
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid authored and rudyfly committed Apr 23, 2019
1 parent 6d3ef49 commit 4ad5f91
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ctrd/supervisord/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
}
18 changes: 17 additions & 1 deletion ctrd/supervisord/option.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package supervisord

import "fmt"
import (
"fmt"
)

// WithGRPCAddress sets the containerd address.
func WithGRPCAddress(addr string) Opt {
Expand Down Expand Up @@ -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
}
}
1 change: 1 addition & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 4ad5f91

Please sign in to comment.