Skip to content

Commit

Permalink
add some e2e tests (unfinished) + fix findMountPoint bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nickorlow committed Apr 24, 2023
1 parent 165d057 commit 405a5aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/util/runtime/cpu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
func NumCPU() int {
cpus := runtime.NumCPU()

cgroupPath, err := libcontainercgroups.FindCgroupMountpoint("", "cpu")
if err != nil {
return cpus
}
Expand All @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 405a5aa

Please sign in to comment.