build(deps): bump github.com/KimMachineGun/automemlimit

Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.7.4 to 0.7.5.
- [Release notes](https://github.com/KimMachineGun/automemlimit/releases)
- [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.7.4...v0.7.5)

---
updated-dependencies:
- dependency-name: github.com/KimMachineGun/automemlimit
  dependency-version: 0.7.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-11-10 10:36:18 +01:00
committed by Ralf Haferkamp
parent 93d84478a4
commit 12ec18be5c
4 changed files with 39 additions and 6 deletions
+35 -2
View File
@@ -103,8 +103,8 @@ func getMemoryLimitV2(chs []cgroupHierarchy, mis []mountInfo) (uint64, error) {
return 0, err
}
// retrieve the memory limit from the memory.max file
return readMemoryLimitV2FromPath(filepath.Join(cgroupPath, "memory.max"))
// retrieve the memory limit from the memory.max recursively.
return walkCgroupV2Hierarchy(cgroupPath, mountPoint)
}
// readMemoryLimitV2FromPath reads the memory limit for cgroup v2 from the given path.
@@ -131,6 +131,39 @@ func readMemoryLimitV2FromPath(path string) (uint64, error) {
return limit, nil
}
// walkCgroupV2Hierarchy walks up the cgroup v2 hierarchy to find the most restrictive memory limit.
func walkCgroupV2Hierarchy(cgroupPath, mountPoint string) (uint64, error) {
var (
found = false
minLimit uint64 = math.MaxUint64
currentPath = cgroupPath
)
for {
limit, err := readMemoryLimitV2FromPath(filepath.Join(currentPath, "memory.max"))
if err != nil && !errors.Is(err, ErrNoLimit) {
return 0, err
} else if err == nil {
found = true
minLimit = min(minLimit, limit)
}
if currentPath == mountPoint {
break
}
parent := filepath.Dir(currentPath)
if parent == currentPath {
break
}
currentPath = parent
}
if !found {
return 0, ErrNoLimit
}
return minLimit, nil
}
// getMemoryLimitV1 retrieves the memory limit from the cgroup v1 controller.
func getMemoryLimitV1(chs []cgroupHierarchy, mis []mountInfo) (uint64, error) {
// find the cgroup v1 path for the memory controller.