ran gofmt
This commit is contained in:
parent
221e85f6f2
commit
3ae35a045d
1 changed files with 17 additions and 17 deletions
|
@ -43,9 +43,9 @@ func NumCPU() int {
|
||||||
return cpus
|
return cpus
|
||||||
}
|
}
|
||||||
|
|
||||||
cgroupVersion := getCgroupVersion();
|
cgroupVersion := getCgroupVersion()
|
||||||
cpuQuota := -1;
|
cpuQuota := -1
|
||||||
cpuPeriod := -1;
|
cpuPeriod := -1
|
||||||
|
|
||||||
if cgroupVersion == 1 {
|
if cgroupVersion == 1 {
|
||||||
cpuQuota := readCgroupFileToInt64(cgroupPath, "cpu.cfs_quota_us")
|
cpuQuota := readCgroupFileToInt64(cgroupPath, "cpu.cfs_quota_us")
|
||||||
|
@ -64,9 +64,9 @@ func NumCPU() int {
|
||||||
func getCgroupVersion() int64 {
|
func getCgroupVersion() int64 {
|
||||||
// /sys/fs/cgroup/cgroup.controllers will not exist with cgroupsv1
|
// /sys/fs/cgroup/cgroup.controllers will not exist with cgroupsv1
|
||||||
if _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil {
|
if _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil {
|
||||||
return 2;
|
return 2
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,36 +74,36 @@ func readCgroup2FileToInt64Tuple(cgroupPath, cgroupFile string) (int64, int64) {
|
||||||
contents, err := os.ReadFile(filepath.Join(cgroupPath, cgroupFile))
|
contents, err := os.ReadFile(filepath.Join(cgroupPath, cgroupFile))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, -1;
|
return -1, -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// file contents looks like: $MAX $PERIOD
|
// file contents looks like: $MAX $PERIOD
|
||||||
// $MAX can have value "max" indicating no limit
|
// $MAX can have value "max" indicating no limit
|
||||||
// it is possible for $PERIOD to be unset
|
// it is possible for $PERIOD to be unset
|
||||||
|
|
||||||
values := strings.Fields(string(contents));
|
values := strings.Fields(string(contents))
|
||||||
|
|
||||||
if values[0] == "max" {
|
if values[0] == "max" {
|
||||||
return -1, -1;
|
return -1, -1
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuQuota, err := strconv.ParseInt(values[0], 10, 64);
|
cpuQuota, err := strconv.ParseInt(values[0], 10, 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, -1;
|
return -1, -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(values) == 1 {
|
if len(values) == 1 {
|
||||||
return cpuQuota, 1;
|
return cpuQuota, 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuPeriod, err := strconv.ParseInt(values[1], 10, 64);
|
cpuPeriod, err := strconv.ParseInt(values[1], 10, 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, -1;
|
return -1, -1
|
||||||
}
|
}
|
||||||
|
|
||||||
return cpuQuota, cpuPeriod;
|
return cpuQuota, cpuPeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
func readCgroupFileToInt64(cgroupPath, cgroupFile string) int64 {
|
func readCgroupFileToInt64(cgroupPath, cgroupFile string) int64 {
|
||||||
|
|
Loading…
Reference in a new issue