Skip to content

Commit

Permalink
metrics: fix collecting hugetlb statistics from cgroup v1
Browse files Browse the repository at this point in the history
- Hugetlb statistics collector matched both usage and (later added)
  reservation accounting files (*.rsvd.*). When both were present, the
  collector tried to create duplicate metrics entries: usage and
  reservation values got the same name and labels.
- This patch ignores *.rsvd.* files when collecting statistics
  in order to keep reporting exactly what was reported before them.
- Fixes error "cgroup_hugetlb_usage... collected before with the same
  name and label values" error in cri-resmgr output.
- Fixes issue #859.
  • Loading branch information
askervin committed Dec 23, 2022
1 parent 7d464f9 commit b9e381c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cgroups/cgroupstats.go
Expand Up @@ -307,6 +307,10 @@ func GetHugetlbUsage(cgroupPath string) ([]HugetlbUsage, error) {
result := make([]HugetlbUsage, 0, len(usageFiles))

for _, file := range usageFiles {
if strings.Contains(filepath.Base(file), ".rsvd") {
// Skip reservations files.
continue
}
size := strings.SplitN(filepath.Base(file), ".", 3)[1]
bytes, err := readCgroupSingleNumber(file)
if err != nil {
Expand Down

0 comments on commit b9e381c

Please sign in to comment.