fix: parsing v2 and v1 cgroup memory limit (#19153)

Trim the newline at the end of the sysfs memory limit.
This commit is contained in:
Anis Eleuch 2024-02-28 23:52:20 +01:00 committed by GitHub
parent 40fb3371fa
commit 9a7c7ab2d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,6 +22,7 @@ import (
"os"
"runtime"
"strconv"
"strings"
"sync"
"time"
@ -70,7 +71,7 @@ func cgroupMemLimit() (limit uint64) {
if err != nil {
return 0
}
limit, err = strconv.ParseUint(string(buf), 10, 64)
limit, err = strconv.ParseUint(strings.TrimSpace(string(buf)), 10, 64)
if err != nil {
// The kernel can return valid but non integer values
// but still, no need to interpret more