daemon.UsingSystemd(): don't call getCD() multiple times

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-09-24 13:51:39 +02:00
parent ed83e2e20e
commit 3ce1dcc25d
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -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