mirror of https://github.com/k3s-io/k3s
Handle the case when systemd lives under `/init.scope`
Signed-off-by: Chris Kim <oats87g@gmail.com>pull/2655/head
parent
6196098f81
commit
c399f87af1
|
@ -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.
|
// 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.
|
// 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
|
// 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.
|
// a host PID scenario but we don't support this.
|
||||||
g, err := os.Open("/proc/1/cgroup")
|
g, err := os.Open("/proc/1/cgroup")
|
||||||
|
@ -218,7 +219,7 @@ func checkCgroups() (root string, hasCFS bool, hasPIDs bool) {
|
||||||
for _, system := range systems {
|
for _, system := range systems {
|
||||||
if system == "name=systemd" {
|
if system == "name=systemd" {
|
||||||
last := parts[len(parts)-1]
|
last := parts[len(parts)-1]
|
||||||
if last != "/" {
|
if last != "/" && last != "/init.scope" {
|
||||||
root = "/systemd"
|
root = "/systemd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue