Unverified Commit c324aa86 authored by Chris Kim's avatar Chris Kim Committed by GitHub

Merge pull request #2655 from Oats87/issues/k3s/2548-119-suppl

[Backport 1.19] Add check for `/init.scope` for cgroup
parents d2fac7b4 c399f87a
......@@ -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"
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment