Pārlūkot izejas kodu

Merge pull request #42878 from thaJeztah/daemon_check_cd_once

daemon.UsingSystemd(): don't call getCD() multiple times
Tianon Gravi 3 gadi atpakaļ
vecāks
revīzija
1430d849a4
1 mainītis faili ar 4 papildinājumiem un 2 dzēšanām
  1. 4 2
      daemon/daemon_unix.go

+ 4 - 2
daemon/daemon_unix.go

@@ -628,11 +628,13 @@ func verifyCgroupDriver(config *config.Config) error {
 
 
 // UsingSystemd returns true if cli option includes native.cgroupdriver=systemd
 // UsingSystemd returns true if cli option includes native.cgroupdriver=systemd
 func UsingSystemd(config *config.Config) bool {
 func UsingSystemd(config *config.Config) bool {
-	if getCD(config) == cgroupSystemdDriver {
+	cd := getCD(config)
+
+	if cd == cgroupSystemdDriver {
 		return true
 		return true
 	}
 	}
 	// On cgroup v2 hosts, default to systemd driver
 	// 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 true
 	}
 	}
 	return false
 	return false