mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
libcontainerd/supervisor: don't write log-level to config file
the `--log-level` flag overrides whatever is in the containerd configuration file;
f033f6ff85/cmd/containerd/command/main.go (L339-L352)
Given that we set that flag when we start the containerd binary, there is no need
to write it both to the generated config-file and pass it as flag.
This patch also slightly changes the behavior; as both dockerd and containerd use
"info" as default log-level, don't set the log-level if it's the default.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
bff3e85625
commit
b6b0b0a05f
3 changed files with 17 additions and 9 deletions
|
@ -589,13 +589,13 @@ func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if cli.Config.Debug {
|
if cli.Debug {
|
||||||
opts = append(opts, supervisor.WithLogLevel("debug"))
|
opts = append(opts, supervisor.WithLogLevel("debug"))
|
||||||
} else if cli.Config.LogLevel != "" {
|
} else {
|
||||||
opts = append(opts, supervisor.WithLogLevel(cli.Config.LogLevel))
|
opts = append(opts, supervisor.WithLogLevel(cli.LogLevel))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cli.Config.CriContainerd {
|
if !cli.CriContainerd {
|
||||||
// CRI support in the managed daemon is currently opt-in.
|
// CRI support in the managed daemon is currently opt-in.
|
||||||
//
|
//
|
||||||
// It's disabled by default, originally because it was listening on
|
// It's disabled by default, originally because it was listening on
|
||||||
|
|
|
@ -48,6 +48,10 @@ type remote struct {
|
||||||
|
|
||||||
// oomScore adjusts the OOM score for the containerd process.
|
// oomScore adjusts the OOM score for the containerd process.
|
||||||
oomScore int
|
oomScore int
|
||||||
|
|
||||||
|
// logLevel overrides the containerd logging-level through the --log-level
|
||||||
|
// command-line option.
|
||||||
|
logLevel string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Daemon represents a running containerd daemon
|
// Daemon represents a running containerd daemon
|
||||||
|
@ -180,8 +184,8 @@ func (r *remote) startContainerd() error {
|
||||||
|
|
||||||
args := []string{"--config", configFile}
|
args := []string{"--config", configFile}
|
||||||
|
|
||||||
if r.Debug.Level != "" {
|
if r.logLevel != "" {
|
||||||
args = append(args, "--log-level", r.Debug.Level)
|
args = append(args, "--log-level", r.logLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command(binaryName, args...)
|
cmd := exec.Command(binaryName, args...)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
|
package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
|
||||||
|
|
||||||
// WithLogLevel defines which log level to starts containerd with.
|
// WithLogLevel defines which log level to start containerd with.
|
||||||
// This only makes sense if WithStartDaemon() was set to true.
|
|
||||||
func WithLogLevel(lvl string) DaemonOpt {
|
func WithLogLevel(lvl string) DaemonOpt {
|
||||||
return func(r *remote) error {
|
return func(r *remote) error {
|
||||||
r.Debug.Level = lvl
|
if lvl == "info" {
|
||||||
|
// both dockerd and containerd default log-level is "info",
|
||||||
|
// so don't pass the default.
|
||||||
|
lvl = ""
|
||||||
|
}
|
||||||
|
r.logLevel = lvl
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue