From 3ce1dcc25d32a9067025ecb9a4870f7a7a28f003 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 24 Sep 2021 13:51:39 +0200 Subject: [PATCH] daemon.UsingSystemd(): don't call getCD() multiple times Signed-off-by: Sebastiaan van Stijn --- daemon/daemon_unix.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go index d96fa805db..86d685d36d 100644 --- a/daemon/daemon_unix.go +++ b/daemon/daemon_unix.go @@ -628,11 +628,13 @@ func verifyCgroupDriver(config *config.Config) error { // UsingSystemd returns true if cli option includes native.cgroupdriver=systemd func UsingSystemd(config *config.Config) bool { - if getCD(config) == cgroupSystemdDriver { + cd := getCD(config) + + if cd == cgroupSystemdDriver { return true } // On cgroup v2 hosts, default to systemd driver - if getCD(config) == "" && cgroups.Mode() == cgroups.Unified && isRunningSystemd() { + if cd == "" && cgroups.Mode() == cgroups.Unified && isRunningSystemd() { return true } return false