Merge pull request #2410 from lifubang/swap0patch
cgroupv2: never write empty string to memory.swap.max
This commit is contained in:
commit
67fac528d0
|
@ -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 != "" {
|
||||
|
|
Loading…
Reference in New Issue