diff --git a/bundle/lib/source/DobbySpecConfig.cpp b/bundle/lib/source/DobbySpecConfig.cpp index 326d428a3..d339dfd9e 100644 --- a/bundle/lib/source/DobbySpecConfig.cpp +++ b/bundle/lib/source/DobbySpecConfig.cpp @@ -62,6 +62,10 @@ static const ctemplate::StaticTemplateString USERNS_DISABLED = static const ctemplate::StaticTemplateString MEM_LIMIT = STS_INIT(MEM_LIMIT, "MEM_LIMIT"); +static const ctemplate::StaticTemplateString MEM_SWAP_LIMIT = + STS_INIT(MEM_SWAP_LIMIT, "MEM_SWAP_LIMIT"); + +static constexpr unsigned MEM_SWAP_LIMIT_EXTRA_BYTES = 200u * 1024u * 1024u; static const ctemplate::StaticTemplateString CPU_SHARES_ENABLED = STS_INIT(CPU_SHARES_ENABLED, "CPU_SHARES_ENABLED"); @@ -1274,6 +1278,7 @@ bool DobbySpecConfig::processMemLimit(const Json::Value& value, } dictionary->SetIntValue(MEM_LIMIT, memLimit); + dictionary->SetIntValue(MEM_SWAP_LIMIT, memLimit + MEM_SWAP_LIMIT_EXTRA_BYTES); return true; } diff --git a/bundle/lib/source/templates/OciConfigJson1.0.2-dobby.template b/bundle/lib/source/templates/OciConfigJson1.0.2-dobby.template index 381017098..6b9dd85f9 100644 --- a/bundle/lib/source/templates/OciConfigJson1.0.2-dobby.template +++ b/bundle/lib/source/templates/OciConfigJson1.0.2-dobby.template @@ -327,7 +327,9 @@ static const char* ociJsonTemplate = R"JSON( {{/DEV_WHITELIST_SECTION}} ], "memory": { - "limit": {{MEM_LIMIT}} + "limit": {{MEM_LIMIT}}, + "swap": {{MEM_SWAP_LIMIT}}, + "swappiness": 60 }, "cpu": { {{#CPU_SHARES_ENABLED}} diff --git a/bundle/lib/source/templates/OciConfigJsonVM1.0.2-dobby.template b/bundle/lib/source/templates/OciConfigJsonVM1.0.2-dobby.template index ed1bc177f..1dc6eb3bd 100644 --- a/bundle/lib/source/templates/OciConfigJsonVM1.0.2-dobby.template +++ b/bundle/lib/source/templates/OciConfigJsonVM1.0.2-dobby.template @@ -338,7 +338,9 @@ static const char* ociJsonTemplate = R"JSON( {{/DEV_WHITELIST_SECTION}} ], "memory": { - "limit": {{MEM_LIMIT}} + "limit": {{MEM_LIMIT}}, + "swap": {{MEM_SWAP_LIMIT}}, + "swappiness": 60 }, "cpu": { {{#CPU_SHARES_ENABLED}}