Summary
The OCI config templates currently hard-code the cgroup memory.memsw.limit_in_bytes (swap) to the same value as memory.limit_in_bytes, making it impossible to configure swap independently of the memory limit.
"memory": {
"limit": {{MEM_LIMIT}},
"swap": {{MEM_LIMIT}}, <-- always tied to memLimit
"swappiness": 60
},
Proposed Change
New optional swapLimit spec field
Add a new top-level swapLimit field to the Dobby JSON spec. When present it sets the cgroup swap limit independently of memLimit. When absent the behaviour is unchanged — swap defaults to the same value as memLimit (i.e. no additional swap beyond the memory limit).
{
"memLimit": 2998272,
"swapLimit": 5996544
}
The kernel requires memory.memsw.limit_in_bytes >= memory.limit_in_bytes, so an error is returned if swapLimit is set lower than memLimit.
Files to change
| File |
Change |
bundle/lib/source/DobbySpecConfig.cpp |
New MEM_SWAP ctemplate constant; JSON_FLAG_SWAPLIMIT flag; new processSwapLimit() processor registered in the field map; step-5 default sets MEM_SWAP = memLimit when swapLimit is absent |
bundle/lib/include/DobbySpecConfig.h |
Declaration of processSwapLimit() |
bundle/lib/source/templates/OciConfigJson1.0.2-dobby.template |
"swap": {{MEM_SWAP}} (was {{MEM_LIMIT}}) |
bundle/lib/source/templates/OciConfigJsonVM1.0.2-dobby.template |
Same template fix |
Backward compatibility
Fully backward compatible. Existing specs that only specify memLimit produce identical OCI output to before.
Summary
The OCI config templates currently hard-code the cgroup
memory.memsw.limit_in_bytes(swap) to the same value asmemory.limit_in_bytes, making it impossible to configure swap independently of the memory limit.Proposed Change
New optional
swapLimitspec fieldAdd a new top-level
swapLimitfield to the Dobby JSON spec. When present it sets the cgroup swap limit independently ofmemLimit. When absent the behaviour is unchanged — swap defaults to the same value asmemLimit(i.e. no additional swap beyond the memory limit).{ "memLimit": 2998272, "swapLimit": 5996544 }The kernel requires
memory.memsw.limit_in_bytes >= memory.limit_in_bytes, so an error is returned ifswapLimitis set lower thanmemLimit.Files to change
bundle/lib/source/DobbySpecConfig.cppMEM_SWAPctemplate constant;JSON_FLAG_SWAPLIMITflag; newprocessSwapLimit()processor registered in the field map; step-5 default setsMEM_SWAP = memLimitwhenswapLimitis absentbundle/lib/include/DobbySpecConfig.hprocessSwapLimit()bundle/lib/source/templates/OciConfigJson1.0.2-dobby.template"swap": {{MEM_SWAP}}(was{{MEM_LIMIT}})bundle/lib/source/templates/OciConfigJsonVM1.0.2-dobby.templateBackward compatibility
Fully backward compatible. Existing specs that only specify
memLimitproduce identical OCI output to before.