Skip to content

Commit

Permalink
Merge pull request #2300 from kolyshkin/fix-max
Browse files Browse the repository at this point in the history
cgroupv2: only treat -1 as "max"
  • Loading branch information
crosbymichael authored Apr 8, 2020
2 parents d3fdacb + 568cd62 commit 5c15da9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libcontainer/cgroups/fs2/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ import (

// numToStr converts an int64 value to a string for writing to a
// cgroupv2 files with .min, .max, .low, or .high suffix.
// Negative values are converted to "max" for cgroupv1 compatibility
// The value of -1 is converted to "max" for cgroupv1 compatibility
// (which used to write -1 to remove the limit).
func numToStr(value int64) (ret string) {
if value > 0 {
ret = strconv.FormatInt(value, 10)
} else if value < 0 {
ret = "max"
} else {
switch {
case value == 0:
ret = ""
case value == -1:
ret = "max"
default:
ret = strconv.FormatInt(value, 10)
}

return ret
Expand Down

0 comments on commit 5c15da9

Please sign in to comment.