Set unified mountpoint in find mnt func
This is needed for the fsv2 cgroups to work when there is a unified mountpoint. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
c1485a1e88
commit
b28f58f31b
|
@ -22,6 +22,7 @@ import (
|
||||||
const (
|
const (
|
||||||
CgroupNamePrefix = "name="
|
CgroupNamePrefix = "name="
|
||||||
CgroupProcesses = "cgroup.procs"
|
CgroupProcesses = "cgroup.procs"
|
||||||
|
unifiedMountpoint = "/sys/fs/cgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -40,7 +41,7 @@ var HugePageSizeUnitList = []string{"B", "KB", "MB", "GB", "TB", "PB"}
|
||||||
func IsCgroup2UnifiedMode() bool {
|
func IsCgroup2UnifiedMode() bool {
|
||||||
isUnifiedOnce.Do(func() {
|
isUnifiedOnce.Do(func() {
|
||||||
var st syscall.Statfs_t
|
var st syscall.Statfs_t
|
||||||
if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil {
|
if err := syscall.Statfs(unifiedMountpoint, &st); err != nil {
|
||||||
panic("cannot statfs cgroup root")
|
panic("cannot statfs cgroup root")
|
||||||
}
|
}
|
||||||
isUnified = st.Type == unix.CGROUP2_SUPER_MAGIC
|
isUnified = st.Type == unix.CGROUP2_SUPER_MAGIC
|
||||||
|
@ -50,6 +51,9 @@ func IsCgroup2UnifiedMode() bool {
|
||||||
|
|
||||||
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
|
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
|
||||||
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
|
func FindCgroupMountpoint(cgroupPath, subsystem string) (string, error) {
|
||||||
|
if IsCgroup2UnifiedMode() {
|
||||||
|
return unifiedMountpoint, nil
|
||||||
|
}
|
||||||
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem)
|
mnt, _, err := FindCgroupMountpointAndRoot(cgroupPath, subsystem)
|
||||||
return mnt, err
|
return mnt, err
|
||||||
}
|
}
|
||||||
|
@ -235,8 +239,8 @@ func GetCgroupMounts(all bool) ([]Mount, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
m := Mount{
|
m := Mount{
|
||||||
Mountpoint: "/sys/fs/cgroup",
|
Mountpoint: unifiedMountpoint,
|
||||||
Root: "/sys/fs/cgroup",
|
Root: unifiedMountpoint,
|
||||||
Subsystems: availableControllers,
|
Subsystems: availableControllers,
|
||||||
}
|
}
|
||||||
return []Mount{m}, nil
|
return []Mount{m}, nil
|
||||||
|
|
Loading…
Reference in New Issue