daemon: do not use pointers to map
Also, do not shadow err with := Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
33ae7d4c19
commit
44c280afbf
4 changed files with 19 additions and 17 deletions
|
@ -961,25 +961,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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue