Skip to content

Commit b6b0b0a

Browse files
committed
libcontainerd/supervisor: don't write log-level to config file
the `--log-level` flag overrides whatever is in the containerd configuration file; https://github.com/containerd/containerd/blob/f033f6ff85ce397202ee69de22b4e3a4bf4093f5/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 <[email protected]>
1 parent bff3e85 commit b6b0b0a

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

cmd/dockerd/daemon.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,13 +589,13 @@ func (cli *DaemonCli) getContainerdDaemonOpts() ([]supervisor.DaemonOpt, error)
589589
return nil, err
590590
}
591591

592-
if cli.Config.Debug {
592+
if cli.Debug {
593593
opts = append(opts, supervisor.WithLogLevel("debug"))
594-
} else if cli.Config.LogLevel != "" {
595-
opts = append(opts, supervisor.WithLogLevel(cli.Config.LogLevel))
594+
} else {
595+
opts = append(opts, supervisor.WithLogLevel(cli.LogLevel))
596596
}
597597

598-
if !cli.Config.CriContainerd {
598+
if !cli.CriContainerd {
599599
// CRI support in the managed daemon is currently opt-in.
600600
//
601601
// It's disabled by default, originally because it was listening on

libcontainerd/supervisor/remote_daemon.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ type remote struct {
4848

4949
// oomScore adjusts the OOM score for the containerd process.
5050
oomScore int
51+
52+
// logLevel overrides the containerd logging-level through the --log-level
53+
// command-line option.
54+
logLevel string
5155
}
5256

5357
// Daemon represents a running containerd daemon
@@ -180,8 +184,8 @@ func (r *remote) startContainerd() error {
180184

181185
args := []string{"--config", configFile}
182186

183-
if r.Debug.Level != "" {
184-
args = append(args, "--log-level", r.Debug.Level)
187+
if r.logLevel != "" {
188+
args = append(args, "--log-level", r.logLevel)
185189
}
186190

187191
cmd := exec.Command(binaryName, args...)

libcontainerd/supervisor/remote_daemon_options.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package supervisor // import "github.com/docker/docker/libcontainerd/supervisor"
22

3-
// WithLogLevel defines which log level to starts containerd with.
4-
// This only makes sense if WithStartDaemon() was set to true.
3+
// WithLogLevel defines which log level to start containerd with.
54
func WithLogLevel(lvl string) DaemonOpt {
65
return func(r *remote) error {
7-
r.Debug.Level = lvl
6+
if lvl == "info" {
7+
// both dockerd and containerd default log-level is "info",
8+
// so don't pass the default.
9+
lvl = ""
10+
}
11+
r.logLevel = lvl
812
return nil
913
}
1014
}

0 commit comments

Comments
 (0)