Browse code

Log active configuration when reloading

When succesfully reloading the daemon configuration, print a message
in the logs with the active configuration:

INFO[2018-01-15T15:36:20.901688317Z] Got signal to reload configuration, reloading from: /etc/docker/daemon.json
INFO[2018-01-14T02:23:48.782769942Z] Reloaded configuration: {"mtu":1500,"pidfile":"/var/run/docker.pid","data-root":"/var/lib/docker","exec-root":"/var/run/docker","group":"docker","deprecated-key-path":"/etc/docker/key.json","max-concurrent-downloads":3,"max-concurrent-uploads":5,"shutdown-timeout":15,"debug":true,"hosts":["unix:///var/run/docker.sock"],"log-level":"info","swarm-default-advertise-addr":"","metrics-addr":"","log-driver":"json-file","ip":"0.0.0.0","icc":true,"iptables":true,"ip-forward":true,"ip-masq":true,"userland-proxy":true,"disable-legacy-registry":true,"experimental":false,"network-control-plane-mtu":1500,"runtimes":{"runc":{"path":"docker-runc"}},"default-runtime":"runc","oom-score-adjust":-500,"default-shm-size":67108864,"default-ipc-mode":"shareable"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2018/01/16 01:11:05
Showing 2 changed files
... ...
@@ -167,7 +167,7 @@ type CommonConfig struct {
167 167
 	sync.Mutex
168 168
 	// FIXME(vdemeester) This part is not that clear and is mainly dependent on cli flags
169 169
 	// It should probably be handled outside this package.
170
-	ValuesSet map[string]interface{}
170
+	ValuesSet map[string]interface{} `json:"-"`
171 171
 
172 172
 	Experimental bool `json:"experimental"` // Experimental indicates whether experimental features should be exposed or not
173 173
 
... ...
@@ -27,11 +27,14 @@ func (daemon *Daemon) Reload(conf *config.Config) (err error) {
27 27
 	attributes := map[string]string{}
28 28
 
29 29
 	defer func() {
30
+		jsonString, _ := json.Marshal(daemon.configStore)
31
+
30 32
 		// we're unlocking here, because
31 33
 		// LogDaemonEventWithAttributes() -> SystemInfo() -> GetAllRuntimes()
32 34
 		// holds that lock too.
33 35
 		daemon.configStore.Unlock()
34 36
 		if err == nil {
37
+			logrus.Infof("Reloaded configuration: %s", jsonString)
35 38
 			daemon.LogDaemonEventWithAttributes("reload", attributes)
36 39
 		}
37 40
 	}()