mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-28 10:47:23 +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
|
||||
}
|
||||
|
||||
func getCgroupMiscCapacity(resource string) int64 {
|
||||
func retrieveCgroupMiscCapacityValue(miscCgroupPath *os.File, resource string) int64 {
|
||||
var totalResources int64 = -1
|
||||
|
||||
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)
|
||||
r := bufio.NewReader(miscCgroupPath)
|
||||
for {
|
||||
line, _, err := r.ReadLine()
|
||||
if err != nil {
|
||||
|
@ -158,3 +151,18 @@ func getCgroupMiscCapacity(resource string) int64 {
|
|||
|
||||
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