mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-31 04:04:51 +00:00
Merge pull request #1265 from fidencio/topic/cpu-misc-cgroups-take-cgroupsv1-into-account
cpu: Take cgroupsv1 into account when reading misc.capacity
This commit is contained in:
commit
fd0ba3f9d9
1 changed files with 17 additions and 9 deletions
|
@ -122,17 +122,10 @@ func sevParameterEnabled(parameter string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCgroupMiscCapacity(resource string) int64 {
|
func retrieveCgroupMiscCapacityValue(miscCgroupPath *os.File, resource string) int64 {
|
||||||
var totalResources int64 = -1
|
var totalResources int64 = -1
|
||||||
|
|
||||||
miscCgroups := hostpath.SysfsDir.Path("fs/cgroup/misc.capacity")
|
r := bufio.NewReader(miscCgroupPath)
|
||||||
f, err := os.Open(miscCgroups)
|
|
||||||
if err != nil {
|
|
||||||
return totalResources
|
|
||||||
}
|
|
||||||
defer f.Close()
|
|
||||||
|
|
||||||
r := bufio.NewReader(f)
|
|
||||||
for {
|
for {
|
||||||
line, _, err := r.ReadLine()
|
line, _, err := r.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -158,3 +151,18 @@ func getCgroupMiscCapacity(resource string) int64 {
|
||||||
|
|
||||||
return totalResources
|
return totalResources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCgroupMiscCapacity(resource string) int64 {
|
||||||
|
miscCgroupsPaths := []string{"fs/cgroup/misc.capacity", "fs/cgroup/misc/misc.capacity"}
|
||||||
|
for _, miscCgroupsPath := range miscCgroupsPaths {
|
||||||
|
miscCgroups := hostpath.SysfsDir.Path(miscCgroupsPath)
|
||||||
|
f, err := os.Open(miscCgroups)
|
||||||
|
if err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
return retrieveCgroupMiscCapacityValue(f, resource)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue