move error check

This commit is contained in:
Nicholas Orlowsky 2023-04-25 10:19:07 -05:00
parent aa9a876217
commit 3714c2c426
No known key found for this signature in database
GPG key ID: 58832FD3AC16C706
2 changed files with 18 additions and 8 deletions

View file

@ -38,16 +38,15 @@ import (
func NumCPU() int {
cpus := runtime.NumCPU()
if err != nil {
return cpus
}
cgroupVersion := getCgroupVersion()
cpuQuota := int64(-1)
cpuPeriod := int64(-1)
if cgroupVersion == 1 {
cgroupPath, err := libcontainercgroups.FindCgroupMountpoint("", "cpu")
if err != nil {
return cpus
}
cpuQuota = readCgroupFileToInt64(cgroupPath, "cpu.cfs_quota_us")
cpuPeriod = readCgroupFileToInt64(cgroupPath, "cpu.cfs_period_us")
} else if cgroupVersion == 2 {