From 3d1e40eaa3bea811111a7e0a90f3abe780530ecb Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Tue, 8 Dec 2020 10:26:54 -0800 Subject: [PATCH] Handle the case when systemd lives under `/init.scope` Signed-off-by: Chris Kim --- pkg/daemons/agent/agent.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/daemons/agent/agent.go b/pkg/daemons/agent/agent.go index 217a76e436c..6b603055461 100644 --- a/pkg/daemons/agent/agent.go +++ b/pkg/daemons/agent/agent.go @@ -200,6 +200,7 @@ func checkCgroups() (root string, hasCFS bool, hasPIDs bool) { // Examine process ID 1 to see if there is a cgroup assigned to it. // When we are not in a container, process 1 is likely to be systemd or some other service manager. + // It either lives at `/` or `/init.scope` according to https://man7.org/linux/man-pages/man7/systemd.special.7.html // When containerized, process 1 will be generally be in a cgroup, otherwise, we may be running in // a host PID scenario but we don't support this. g, err := os.Open("/proc/1/cgroup") @@ -218,7 +219,7 @@ func checkCgroups() (root string, hasCFS bool, hasPIDs bool) { for _, system := range systems { if system == "name=systemd" { last := parts[len(parts)-1] - if last != "/" { + if last != "/" && last != "/init.scope" { root = "/systemd" } }