Ensure we never set more memory than swap for containers

This commit is contained in:
Johannes Zellner
2024-01-24 15:54:57 +01:00
parent 793ee38f79
commit 2d1e0ec890

View File

@@ -219,7 +219,10 @@ async function getMemoryAllocation(limit) {
ratio = Math.round(pc * 10) / 10; // a simple ratio
}
return Math.round(Math.round(limit * ratio) / 1048576) * 1048576; // nearest MB
const memoryAllocation = Math.round(Math.round(limit * ratio) / 1048576) * 1048576; // nearest MB
// make sure we never overshoot if the ratio is quite far off (high RAM low swap)
return memoryAllocation > limit ? limit : memoryAllocation;
}
async function getDiskUsage() {