mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
Containers specific case: if total memory taken from cgroups is lower than system memory taken from psutil, calculate memory usage based on information from cgroups. The formula idea is taken from https://github.com/moby/moby/issues/40727#issuecomment-604155288 Closes #1780 Tests performed: - In a non-container environment, filled the memory 90% ``` stress-ng --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.9;}' \ < /proc/meminfo)k --vm-keep -m 1 ``` and ensured that correct notification is shown. - In a container, if no memory limitations are set, notifications are based on host memory usage - In a container, if memory limits are set ``` systemctl set-property systemd-nspawn@fbx-testing.service MemoryMax=200M ``` ensured that the notification is shown and is calculated based on cgroups. Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil: Fix i18n for notification message] [sunil: Drop unnecessary type conversion] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>