From 8a8cdaaa11a5efb8082ccad300e439f41bfcf40c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 7 Mar 2025 00:08:45 +0100 Subject: [PATCH] cmd/dockerd: daemonCLI.start: don't log warnings before failing This function could produce various logs ("Running in rootless mode") at the start, but further steps could still fail (such as running with RootlessKit, but not being configured as rootless). This patch moves the informational / warning logs further down, so that we don't produce logs before failing. Signed-off-by: Sebastiaan van Stijn --- cmd/dockerd/daemon.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/cmd/dockerd/daemon.go b/cmd/dockerd/daemon.go index ae7d436a56..36fd222b1e 100644 --- a/cmd/dockerd/daemon.go +++ b/cmd/dockerd/daemon.go @@ -113,18 +113,8 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) { debug.Enable() } - if cli.Config.Experimental { - log.G(ctx).Warn("Running experimental build") - } - - if cli.Config.IsRootless() { - log.G(ctx).Warn("Running in rootless mode. This mode has feature limitations.") - } - if rootless.RunningWithRootlessKit() { - log.G(ctx).Info("Running with RootlessKit integration") - if !cli.Config.IsRootless() { - return fmt.Errorf("rootless mode needs to be enabled for running with RootlessKit") - } + if rootless.RunningWithRootlessKit() && !cli.Config.IsRootless() { + return fmt.Errorf("rootless mode needs to be enabled for running with RootlessKit") } // return human-friendly error before creating files @@ -164,12 +154,20 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) { } if cli.Config.IsRootless() { + log.G(ctx).Warn("Running in rootless mode. This mode has feature limitations.") + if rootless.RunningWithRootlessKit() { + log.G(ctx).Info("Running with RootlessKit integration") + } + // Set sticky bit if XDG_RUNTIME_DIR is set && the file is actually under XDG_RUNTIME_DIR if _, err := homedir.StickRuntimeDirContents(potentiallyUnderRuntimeDir); err != nil { // StickRuntimeDirContents returns nil error if XDG_RUNTIME_DIR is just unset log.G(ctx).WithError(err).Warn("cannot set sticky bit on files under XDG_RUNTIME_DIR") } } + if cli.Config.Experimental { + log.G(ctx).Warn("Running with experimental features enabled") + } lss, hosts, err := loadListeners(cli.Config, cli.apiTLSConfig) if err != nil {