add some e2e tests (unfinished) + fix findMountPoint bug
This commit is contained in:
parent
165d057361
commit
405a5aa44c
1 changed files with 3 additions and 3 deletions
|
@ -38,7 +38,6 @@ import (
|
||||||
func NumCPU() int {
|
func NumCPU() int {
|
||||||
cpus := runtime.NumCPU()
|
cpus := runtime.NumCPU()
|
||||||
|
|
||||||
cgroupPath, err := libcontainercgroups.FindCgroupMountpoint("", "cpu")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cpus
|
return cpus
|
||||||
}
|
}
|
||||||
|
@ -48,10 +47,11 @@ func NumCPU() int {
|
||||||
cpuPeriod := int64(-1)
|
cpuPeriod := int64(-1)
|
||||||
|
|
||||||
if cgroupVersion == 1 {
|
if cgroupVersion == 1 {
|
||||||
|
cgroupPath, err := libcontainercgroups.FindCgroupMountpoint("", "cpu")
|
||||||
cpuQuota = readCgroupFileToInt64(cgroupPath, "cpu.cfs_quota_us")
|
cpuQuota = readCgroupFileToInt64(cgroupPath, "cpu.cfs_quota_us")
|
||||||
cpuPeriod = readCgroupFileToInt64(cgroupPath, "cpu.cfs_period_us")
|
cpuPeriod = readCgroupFileToInt64(cgroupPath, "cpu.cfs_period_us")
|
||||||
} else if cgroupVersion == 2 {
|
} else if cgroupVersion == 2 {
|
||||||
cpuQuota, cpuPeriod = readCgroup2FileToInt64Tuple(cgroupPath, "cpu.max")
|
cpuQuota, cpuPeriod = readCgroup2FileToInt64Tuple("cpu.max")
|
||||||
}
|
}
|
||||||
|
|
||||||
if cpuQuota == -1 || cpuPeriod == -1 {
|
if cpuQuota == -1 || cpuPeriod == -1 {
|
||||||
|
@ -71,7 +71,7 @@ func getCgroupVersion() int64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readCgroup2FileToInt64Tuple(cgroupPath, cgroupFile string) (int64, 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 {
|
if err != nil {
|
||||||
return -1, -1
|
return -1, -1
|
||||||
|
|
Loading…
Reference in a new issue