From f90056a79d114c529048138027a7834b293a1a47 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 7 Jun 2022 02:47:48 +0200 Subject: [PATCH] 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 --- daemon/events.go | 9 ++++----- daemon/reload.go | 4 ---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/daemon/events.go b/daemon/events.go index c2a064fe46..1812c0eebf 100644 --- a/daemon/events.go +++ b/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. func (daemon *Daemon) LogDaemonEventWithAttributes(action string, attributes map[string]string) { 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, Attributes: attributes, - } - daemon.EventsService.Log(action, events.DaemonEventType, actor) + }) } } diff --git a/daemon/reload.go b/daemon/reload.go index c8e256557d..20f1b8eacf 100644 --- a/daemon/reload.go +++ b/daemon/reload.go @@ -42,10 +42,6 @@ func (daemon *Daemon) Reload(conf *config.Config) (err error) { }) logrus.Infof("Reloaded configuration: %s", jsonString) } - - // we're unlocking here, because - // LogDaemonEventWithAttributes() -> SystemInfo() -> GetAllRuntimes() - // holds that lock too. daemon.configStore.Unlock() if err == nil { daemon.LogDaemonEventWithAttributes("reload", attributes)