move error check
This commit is contained in:
parent
aa9a876217
commit
3714c2c426
2 changed files with 18 additions and 8 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue