Also, do not shadow err with :=
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
| ... | ... |
@@ -961,25 +961,23 @@ func (daemon *Daemon) initDiscovery(config *Config) error {
|
| 961 | 961 |
// - Daemon max concurrent uploads |
| 962 | 962 |
// - Cluster discovery (reconfigure and restart). |
| 963 | 963 |
// - Daemon live restore |
| 964 |
-func (daemon *Daemon) Reload(config *Config) error {
|
|
| 965 |
- var err error |
|
| 966 |
- // used to hold reloaded changes |
|
| 967 |
- attributes := map[string]string{}
|
|
| 964 |
+func (daemon *Daemon) Reload(config *Config) (err error) {
|
|
| 965 |
+ |
|
| 966 |
+ daemon.configStore.reloadLock.Lock() |
|
| 967 |
+ |
|
| 968 |
+ attributes := daemon.platformReload(config) |
|
| 968 | 969 |
|
| 969 |
- // We need defer here to ensure the lock is released as |
|
| 970 |
- // daemon.SystemInfo() will try to get it too |
|
| 971 | 970 |
defer func() {
|
| 971 |
+ // we're unlocking here, because |
|
| 972 |
+ // LogDaemonEventWithAttributes() -> SystemInfo() -> GetAllRuntimes() |
|
| 973 |
+ // holds that lock too. |
|
| 974 |
+ daemon.configStore.reloadLock.Unlock() |
|
| 972 | 975 |
if err == nil {
|
| 973 | 976 |
daemon.LogDaemonEventWithAttributes("reload", attributes)
|
| 974 | 977 |
} |
| 975 | 978 |
}() |
| 976 | 979 |
|
| 977 |
- daemon.configStore.reloadLock.Lock() |
|
| 978 |
- defer daemon.configStore.reloadLock.Unlock() |
|
| 979 |
- |
|
| 980 |
- daemon.platformReload(config, &attributes) |
|
| 981 |
- |
|
| 982 |
- if err = daemon.reloadClusterDiscovery(config); err != nil {
|
|
| 980 |
+ if err := daemon.reloadClusterDiscovery(config); err != nil {
|
|
| 983 | 981 |
return err |
| 984 | 982 |
} |
| 985 | 983 |
|
| ... | ... |
@@ -78,7 +78,8 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. |
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 | 80 |
// platformReload update configuration with platform specific options |
| 81 |
-func (daemon *Daemon) platformReload(config *Config, attributes *map[string]string) {
|
|
| 81 |
+func (daemon *Daemon) platformReload(config *Config) map[string]string {
|
|
| 82 |
+ return map[string]string{}
|
|
| 82 | 83 |
} |
| 83 | 84 |
|
| 84 | 85 |
// verifyDaemonSettings performs validation of daemon config struct |
| ... | ... |
@@ -516,7 +516,7 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. |
| 516 | 516 |
} |
| 517 | 517 |
|
| 518 | 518 |
// platformReload update configuration with platform specific options |
| 519 |
-func (daemon *Daemon) platformReload(config *Config, attributes *map[string]string) {
|
|
| 519 |
+func (daemon *Daemon) platformReload(config *Config) map[string]string {
|
|
| 520 | 520 |
if config.IsValueSet("runtimes") {
|
| 521 | 521 |
daemon.configStore.Runtimes = config.Runtimes |
| 522 | 522 |
// Always set the default one |
| ... | ... |
@@ -536,8 +536,10 @@ func (daemon *Daemon) platformReload(config *Config, attributes *map[string]stri |
| 536 | 536 |
runtimeList.WriteString(fmt.Sprintf("%s:%s", name, rt))
|
| 537 | 537 |
} |
| 538 | 538 |
|
| 539 |
- (*attributes)["runtimes"] = runtimeList.String() |
|
| 540 |
- (*attributes)["default-runtime"] = daemon.configStore.DefaultRuntime |
|
| 539 |
+ return map[string]string{
|
|
| 540 |
+ "runtimes": runtimeList.String(), |
|
| 541 |
+ "default-runtime": daemon.configStore.DefaultRuntime, |
|
| 542 |
+ } |
|
| 541 | 543 |
} |
| 542 | 544 |
|
| 543 | 545 |
// verifyDaemonSettings performs validation of daemon config struct |
| ... | ... |
@@ -153,7 +153,8 @@ func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *containertypes. |
| 153 | 153 |
} |
| 154 | 154 |
|
| 155 | 155 |
// platformReload update configuration with platform specific options |
| 156 |
-func (daemon *Daemon) platformReload(config *Config, attributes *map[string]string) {
|
|
| 156 |
+func (daemon *Daemon) platformReload(config *Config) map[string]string {
|
|
| 157 |
+ return map[string]string{}
|
|
| 157 | 158 |
} |
| 158 | 159 |
|
| 159 | 160 |
// verifyDaemonSettings performs validation of daemon config struct |