never write empty string to memory.swap.max
Because the empty string means set swap to 0.
@@ -50,9 +50,12 @@ func setMemory(dirPath string, cgroup *configs.Cgroup) error {
// memory and memorySwap set to the same value -- disable swap
swapStr = "0"
}
+ // 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 != "" {
if err := fscommon.WriteFile(dirPath, "memory.max", val); err != nil {
