diff --git a/daemon/daemon.go b/daemon/daemon.go index 5aaef55987..9a07e5ce2e 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -968,25 +968,23 @@ func (daemon *Daemon) initDiscovery(config *Config) error { // - Daemon max concurrent uploads // - Cluster discovery (reconfigure and restart). // - Daemon live restore -func (daemon *Daemon) Reload(config *Config) error { - var err error - // used to hold reloaded changes - attributes := map[string]string{} +func (daemon *Daemon) Reload(config *Config) (err error) { + + daemon.configStore.reloadLock.Lock() + + attributes := daemon.platformReload(config) - // We need defer here to ensure the lock is released as - // daemon.SystemInfo() will try to get it too defer func() { + // we're unlocking here, because + // LogDaemonEventWithAttributes() -> SystemInfo() -> GetAllRuntimes() + // holds that lock too. + daemon.configStore.reloadLock.Unlock() if err == nil { daemon.LogDaemonEventWithAttributes("reload", attributes) } }() - daemon.configStore.reloadLock.Lock() - defer daemon.configStore.reloadLock.Unlock() - - daemon.platformReload(config, &attributes) - - if err = daemon.reloadClusterDiscovery(config); err != nil { + if err := daemon.reloadClusterDiscovery(config); err != nil { return err } diff --git a/daemon/daemon_solaris.go b/daemon/daemon_solaris.go index b2244a888d..f555156cfd 100644 --- a/daemon/daemon_solaris.go +++ b/daemon/daemon_solaris.go @@ -78,7 +78,8 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. } // platformReload update configuration with platform specific options -func (daemon *Daemon) platformReload(config *Config, attributes *map[string]string) { +func (daemon *Daemon) platformReload(config *Config) map[string]string { + return map[string]string{} } // verifyDaemonSettings performs validation of daemon config struct diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index af6b94f0f1..505a8967b7 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -516,7 +516,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. } // platformReload update configuration with platform specific options -func (daemon *Daemon) platformReload(config *Config, attributes *map[string]string) { +func (daemon *Daemon) platformReload(config *Config) map[string]string { if config.IsValueSet("runtimes") { daemon.configStore.Runtimes = config.Runtimes // Always set the default one @@ -536,8 +536,10 @@ func (daemon *Daemon) platformReload(config *Config, attributes *map[string]stri runtimeList.WriteString(fmt.Sprintf("%s:%s", name, rt)) } - (*attributes)["runtimes"] = runtimeList.String() - (*attributes)["default-runtime"] = daemon.configStore.DefaultRuntime + return map[string]string{ + "runtimes": runtimeList.String(), + "default-runtime": daemon.configStore.DefaultRuntime, + } } // verifyDaemonSettings performs validation of daemon config struct diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go index af45ab84fe..1fda144d69 100644 --- a/daemon/daemon_windows.go +++ b/daemon/daemon_windows.go @@ -153,7 +153,8 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. } // platformReload update configuration with platform specific options -func (daemon *Daemon) platformReload(config *Config, attributes *map[string]string) { +func (daemon *Daemon) platformReload(config *Config) map[string]string { + return map[string]string{} } // verifyDaemonSettings performs validation of daemon config struct