1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

daemon: un-export IsRunningSystemd()

This utility was added after 19.03, and is only used in the daemon code
itself, so we can un-export it, until there's an external use for it.

Also updated the description, because the runc code already copied it
from coreos/go-systemd, so better to describe the actual source.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-11-09 15:15:45 +01:00
parent a8a769f04f
commit e7ba5cacc6
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -638,14 +638,20 @@ func UsingSystemd(config *config.Config) bool {
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 getCD(config) == "" && cgroups.Mode() == cgroups.Unified && isRunningSystemd() {
return true return true
} }
return false return false
} }
// IsRunningSystemd is from https://github.com/opencontainers/runc/blob/46be7b612e2533c494e6a251111de46d8e286ed5/libcontainer/cgroups/systemd/common.go#L27-L33 // isRunningSystemd checks whether the host was booted with systemd as its init
func IsRunningSystemd() bool { // system. This functions similarly to systemd's `sd_booted(3)`: internally, it
// checks whether /run/systemd/system/ exists and is a directory.
// http://www.freedesktop.org/software/systemd/man/sd_booted.html
//
// NOTE: This function comes from package github.com/coreos/go-systemd/util
// It was borrowed here to avoid a dependency on cgo.
func isRunningSystemd() bool {
fi, err := os.Lstat("/run/systemd/system") fi, err := os.Lstat("/run/systemd/system")
if err != nil { if err != nil {
return false return false