瀏覽代碼

daemon: LogDaemonEventWithAttributes: don't call SystemInfo()

This function was calling SystemInfo() only to get the daemon's name
to add to the event that's generated.

SystemInfo() is quite heavy, and no info other than the Name was used.
The name returned is just looking up the hostname, so instead, call
`hostName()` directly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 年之前
父節點
當前提交
f90056a79d
共有 2 個文件被更改,包括 4 次插入9 次删除
  1. 4 5
      daemon/events.go
  2. 0 4
      daemon/reload.go

+ 4 - 5
daemon/events.go

@@ -87,14 +87,13 @@ func (daemon *Daemon) LogNetworkEventWithAttributes(nw libnetwork.Network, actio
 // LogDaemonEventWithAttributes generates an event related to the daemon itself with specific given attributes.
 // LogDaemonEventWithAttributes generates an event related to the daemon itself with specific given attributes.
 func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map[string]string) {
 func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map[string]string) {
 	if daemon.EventsService != nil {
 	if daemon.EventsService != nil {
-		if info := daemon.SystemInfo(); info.Name != "" {
-			attributes["name"] = info.Name
+		if name := hostName(); name != "" {
+			attributes["name"] = name
 		}
 		}
-		actor := events.Actor{
+		daemon.EventsService.Log(action, events.DaemonEventType, events.Actor{
 			ID:         daemon.id,
 			ID:         daemon.id,
 			Attributes: attributes,
 			Attributes: attributes,
-		}
-		daemon.EventsService.Log(action, events.DaemonEventType, actor)
+		})
 	}
 	}
 }
 }
 
 

+ 0 - 4
daemon/reload.go

@@ -42,10 +42,6 @@ func (daemon *Daemon) Reload(conf *config.Config) (err error) {
 			})
 			})
 			logrus.Infof("Reloaded configuration: %s", jsonString)
 			logrus.Infof("Reloaded configuration: %s", jsonString)
 		}
 		}
-
-		// we're unlocking here, because
-		// LogDaemonEventWithAttributes() -> SystemInfo() -> GetAllRuntimes()
-		// holds that lock too.
 		daemon.configStore.Unlock()
 		daemon.configStore.Unlock()
 		if err == nil {
 		if err == nil {
 			daemon.LogDaemonEventWithAttributes("reload", attributes)
 			daemon.LogDaemonEventWithAttributes("reload", attributes)