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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-03-07 00:08:45 +01:00
parent 6e30a4cc0c
commit 8a8cdaaa11

View File

@@ -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 {