1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-31 04:04:51 +00:00

cpu: Take cgroupsv1 into account when reading misc.capacity

We've been only considering cgroupsv2 when trying to read misc.capacity.
However, there are still a bunch of systems out there relying on
cgroupsv1.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-07-19 10:29:24 +02:00
parent 5f181cc6d0
commit 8ed5a2343f

View file

@ -124,13 +124,22 @@ func sevParameterEnabled(parameter string) bool {
func getCgroupMiscCapacity(resource string) int64 {
var totalResources int64 = -1
var err error = nil
var f *os.File = nil
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()
break
}
}
miscCgroups := hostpath.SysfsDir.Path("fs/cgroup/misc.capacity")
f, err := os.Open(miscCgroups)
if err != nil {
return totalResources
}
defer f.Close()
r := bufio.NewReader(f)
for {