Merge pull request #2410 from lifubang/swap0patch

cgroupv2: never write empty string to memory.swap.max
This commit is contained in:
Mrunal Patel 2020-05-18 10:42:17 -07:00 committed by GitHub
commit 67fac528d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -50,8 +50,11 @@ func setMemory(dirPath string, cgroup *configs.Cgroup) error {
// memory and memorySwap set to the same value -- disable swap
swapStr = "0"
}
if err := fscommon.WriteFile(dirPath, "memory.swap.max", swapStr); err != nil {
return err
// never write empty string to `memory.swap.max`, it means set to 0.
if swapStr != "" {
if err := fscommon.WriteFile(dirPath, "memory.swap.max", swapStr); err != nil {
return err
}
}
if val := numToStr(cgroup.Resources.Memory); val != "" {