From 405a5aa44c828d151c62d914e68cd39954370152 Mon Sep 17 00:00:00 2001 From: Nicholas Orlowsky Date: Mon, 24 Apr 2023 11:33:50 -0500 Subject: [PATCH] add some e2e tests (unfinished) + fix findMountPoint bug --- pkg/util/runtime/cpu_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/util/runtime/cpu_linux.go b/pkg/util/runtime/cpu_linux.go index 5228c93a2..4d755f4c5 100644 --- a/pkg/util/runtime/cpu_linux.go +++ b/pkg/util/runtime/cpu_linux.go @@ -38,7 +38,6 @@ import ( func NumCPU() int { cpus := runtime.NumCPU() - cgroupPath, err := libcontainercgroups.FindCgroupMountpoint("", "cpu") if err != nil { return cpus } @@ -48,10 +47,11 @@ func NumCPU() int { cpuPeriod := int64(-1) if cgroupVersion == 1 { + cgroupPath, err := libcontainercgroups.FindCgroupMountpoint("", "cpu") cpuQuota = readCgroupFileToInt64(cgroupPath, "cpu.cfs_quota_us") cpuPeriod = readCgroupFileToInt64(cgroupPath, "cpu.cfs_period_us") } else if cgroupVersion == 2 { - cpuQuota, cpuPeriod = readCgroup2FileToInt64Tuple(cgroupPath, "cpu.max") + cpuQuota, cpuPeriod = readCgroup2FileToInt64Tuple("cpu.max") } if cpuQuota == -1 || cpuPeriod == -1 { @@ -71,7 +71,7 @@ func getCgroupVersion() int64 { } func readCgroup2FileToInt64Tuple(cgroupPath, cgroupFile string) (int64, int64) { - contents, err := os.ReadFile(filepath.Join(cgroupPath, cgroupFile)) + contents, err := os.ReadFile(filepath.Join("/sys/fs/cgroup/", cgroupFile)) if err != nil { return -1, -1