fix(oci): a Compose reservation is not the memory limit of the container

What a Compose file reserves is the least the application is promised, not the most it may use. 81 recipes had taken it as the memory of the container, as low as 128 MB, and the kernel stopped applications such as Home Assistant Official and UniFi Network.

Without a limit in the file the container gets the standard 1024 MB, or the reservation when it is larger. A limit the file sets is kept.
This commit is contained in:
MacRimi
2026-10-11 12:02:04 +02:00
parent 56d7a1839b
commit a552da6f91
85 changed files with 147 additions and 89 deletions
+1 -1
View File
@@ -233,7 +233,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -210,7 +210,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -291,7 +291,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -170,7 +170,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -211,7 +211,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -513,7 +513,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -286,7 +286,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -214,7 +214,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -364,7 +364,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -226,7 +226,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -213,7 +213,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -237,7 +237,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 500,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -244,7 +244,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -211,7 +211,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -261,7 +261,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -371,7 +371,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -238,7 +238,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -231,7 +231,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -318,7 +318,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -173,7 +173,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -249,7 +249,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -237,7 +237,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -300,7 +300,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -211,7 +211,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -242,7 +242,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -243,7 +243,7 @@
"unprivileged": false,
"ostype": "unmanaged",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -211,7 +211,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -288,7 +288,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -247,7 +247,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -407,7 +407,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -254,7 +254,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -294,7 +294,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -237,7 +237,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -296,7 +296,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -467,7 +467,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -275,7 +275,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -207,7 +207,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -389,7 +389,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -238,7 +238,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -230,7 +230,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 320,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -247,7 +247,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -223,7 +223,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -267,7 +267,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -211,7 +211,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -321,7 +321,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -233,7 +233,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -249,7 +249,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -233,7 +233,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -353,7 +353,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -242,7 +242,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -175,7 +175,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -209,7 +209,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -297,7 +297,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -221,7 +221,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -281,7 +281,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -288,7 +288,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -269,7 +269,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -252,7 +252,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -267,7 +267,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -232,7 +232,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -278,7 +278,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -307,7 +307,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -281,7 +281,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -302,7 +302,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -181,7 +181,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -542,7 +542,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -231,7 +231,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
@@ -296,7 +296,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -244,7 +244,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -425,7 +425,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -213,7 +213,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -216,7 +216,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 500,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -342,7 +342,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -211,7 +211,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -260,7 +260,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -231,7 +231,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -221,7 +221,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -242,7 +242,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -890,7 +890,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 128,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -382,7 +382,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 256,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -233,7 +233,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -249,7 +249,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+1 -1
View File
@@ -233,7 +233,7 @@
"unprivileged": true,
"ostype": "auto-from-image",
"cores": 2,
"memory_mb": 512,
"memory_mb": 1024,
"swap_mb": 512,
"rootfs_size_gb": 8,
"rootfs_storage": "local-lvm",
+17 -6
View File
@@ -702,15 +702,26 @@ def _compose_stack_contract(
}
def _memory_mb(service: dict[str, Any]) -> int:
value = (((service.get("deploy") or {}).get("resources") or {}).get("reservations") or {}).get("memory")
def _megabytes(value: Any) -> int | None:
match = re.fullmatch(r"\s*(\d+(?:\.\d+)?)\s*([KMG]?)B?\s*", str(value or ""), re.I)
if not match:
return 1024
number = float(match.group(1))
unit = match.group(2).upper()
return None
factors = {"": 1 / (1024 * 1024), "K": 1 / 1024, "M": 1, "G": 1024}
return max(128, int(number * factors[unit]))
return int(float(match.group(1)) * factors[match.group(2).upper()])
def _memory_mb(service: dict[str, Any]) -> int:
"""The memory the container is given. What a Compose file reserves is the
least the application is promised, not the most it may use: Docker lets it
grow past that, and a container limited to it is stopped by the kernel as
soon as it needs more. A reservation only raises the default; a limit the
file sets is the memory of the container."""
resources = (service.get("deploy") or {}).get("resources") or {}
limit = _megabytes((resources.get("limits") or {}).get("memory"))
reservation = _megabytes((resources.get("reservations") or {}).get("memory")) or 0
if limit:
return max(128, limit, reservation)
return max(1024, reservation)
def _blockers(
+47
View File
@@ -0,0 +1,47 @@
"""What a Compose file reserves for an application is the least it is promised,
not the most it may use. A container limited to that figure is stopped by the
kernel as soon as the application needs more."""
from pathlib import Path
import sys
import unittest
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))
from proxmenux_oci.casaos import _memory_mb
from proxmenux_oci.catalog import Catalog
def service(reservation=None, limit=None):
resources = {}
if reservation:
resources["reservations"] = {"memory": reservation}
if limit:
resources["limits"] = {"memory": limit}
return {"deploy": {"resources": resources}} if resources else {}
class ContainerMemoryTests(unittest.TestCase):
def test_a_reservation_is_not_the_memory_of_the_container(self):
self.assertEqual(_memory_mb(service(reservation="64M")), 1024)
self.assertEqual(_memory_mb(service(reservation="256M")), 1024)
def test_a_larger_reservation_raises_it(self):
self.assertEqual(_memory_mb(service(reservation="2G")), 2048)
def test_a_limit_the_file_sets_is_the_memory_of_the_container(self):
self.assertEqual(_memory_mb(service(limit="512M")), 512)
self.assertEqual(_memory_mb(service(reservation="128M", limit="128M")), 128)
def test_nothing_stated_is_the_default(self):
self.assertEqual(_memory_mb({}), 1024)
def test_the_recipes_that_only_reserve_memory_get_the_default(self):
catalog = Catalog(ROOT)
for app in ("homeassistant-official", "unifi-controller", "grafana", "gitea", "vaultwarden", "uptimekuma"):
self.assertGreaterEqual(catalog.compose(app)["proxmox"]["defaults"]["memory_mb"], 1024, app)
if __name__ == "__main__":
unittest.main()