From c2616be93351e333c0e7fc6716ea2703e8a64972 Mon Sep 17 00:00:00 2001 From: "Simon L." Date: Thu, 27 Aug 2026 09:29:46 +0200 Subject: [PATCH] feat: add oom_score_adj to all AIO containers Assign oom_score_adj per priority tier so the OOM killer targets less critical containers first; parse it from containers.json and apply on create. Signed-off-by: Simon L. Co-authored-by: Claude Opus 5 (1M context) --- php/containers-schema.json | 5 +++ php/containers.json | 57 +++++++++++++++++--------- php/src/Container/Container.php | 1 + php/src/ContainerDefinitionFetcher.php | 6 +++ php/src/Docker/DockerActionManager.php | 4 ++ 5 files changed, 54 insertions(+), 19 deletions(-) diff --git a/php/containers-schema.json b/php/containers-schema.json index 3f7a891d..e5d38ebd 100644 --- a/php/containers-schema.json +++ b/php/containers-schema.json @@ -214,6 +214,11 @@ "pattern": "^/[a-z/_0-9-:]+$" } }, + "oom_score_adj": { + "type": "integer", + "minimum": -500, + "maximum": 500 + }, "volumes": { "type": "array", "items": { diff --git a/php/containers.json b/php/containers.json index fcd63395..2706b697 100644 --- a/php/containers.json +++ b/php/containers.json @@ -82,7 +82,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": -100 }, { "container_name": "nextcloud-aio-database", @@ -139,7 +140,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": -300 }, { "container_name": "nextcloud-aio-nextcloud", @@ -284,7 +286,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": -100 }, { "container_name": "nextcloud-aio-notify-push", @@ -325,7 +328,8 @@ "read_only": true, "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 100 }, { "container_name": "nextcloud-aio-redis", @@ -368,7 +372,8 @@ "read_only": true, "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": -300 }, { "container_name": "nextcloud-aio-collabora", @@ -418,7 +423,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-talk", @@ -488,7 +494,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-talk-recording", @@ -542,7 +549,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-borgbackup", @@ -613,7 +621,8 @@ "tmpfs": [ "/tmp", "/nextcloud_aio_volumes" - ] + ], + "oom_score_adj": -300 }, { "container_name": "nextcloud-aio-watchtower", @@ -636,7 +645,8 @@ "read_only": true, "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": -300 }, { "container_name": "nextcloud-aio-domaincheck", @@ -669,7 +679,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-clamav", @@ -714,7 +725,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-onlyoffice", @@ -758,7 +770,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-eurooffice", @@ -807,7 +820,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-imaginary", @@ -849,7 +863,8 @@ ], "secrets": [ "IMAGINARY_SECRET" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-fulltextsearch", @@ -903,7 +918,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 }, { "container_name": "nextcloud-aio-docker-socket-proxy", @@ -930,7 +946,8 @@ ], "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 100 }, { "container_name": "nextcloud-aio-harp", @@ -982,7 +999,8 @@ ], "profiles": [ "harp" - ] + ], + "oom_score_adj": 100 }, { "container_name": "nextcloud-aio-whiteboard", @@ -1028,7 +1046,8 @@ "read_only": true, "cap_drop": [ "NET_RAW" - ] + ], + "oom_score_adj": 300 } ] } diff --git a/php/src/Container/Container.php b/php/src/Container/Container.php index 6fb43d9a..3df2be23 100644 --- a/php/src/Container/Container.php +++ b/php/src/Container/Container.php @@ -41,6 +41,7 @@ readonly class Container { public AioVariables $aioVariables, public string $documentation, public bool $hideFromList, + public int $oomScoreAdj, private DockerActionManager $dockerActionManager ) { } diff --git a/php/src/ContainerDefinitionFetcher.php b/php/src/ContainerDefinitionFetcher.php index e1c625a0..00c0ebc1 100644 --- a/php/src/ContainerDefinitionFetcher.php +++ b/php/src/ContainerDefinitionFetcher.php @@ -360,6 +360,11 @@ readonly class ContainerDefinitionFetcher { $hideFromList = $entry['hide_from_list'] ?? false; + $oomScoreAdj = 500; + if (isset($entry['oom_score_adj'])) { + $oomScoreAdj = $entry['oom_score_adj']; + } + $containers[] = new Container( $entry['container_name'], $displayName, @@ -387,6 +392,7 @@ readonly class ContainerDefinitionFetcher { $aioVariables, $documentation, $hideFromList, + $oomScoreAdj, $this->container->get(DockerActionManager::class) ); } diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index e6ada057..ec5bb97e 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -414,6 +414,10 @@ readonly class DockerActionManager { $requestBody['StopTimeout'] = $maxShutDownTime; } + if ($container->oomScoreAdj !== 0) { + $requestBody['HostConfig']['OomScoreAdj'] = $container->oomScoreAdj; + } + $capAdds = $container->capAdd; if (count($capAdds) > 0) { $requestBody['HostConfig']['CapAdd'] = $capAdds;