fix: allow disabling per-container memory/CPU caps (CONTAINER_*=0)
All checks were successful
CI / test (push) Successful in 37s

Some hosts can't enforce cgroup limits for nested containers at all
(confirmed on an OpenRC-based unprivileged LXC with no systemd to
delegate cgroup controllers) — docker run fails outright trying to
write memory.max. 0 now skips requesting that cap instead of erroring
every deploy.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 04:38:45 +02:00
parent 698173c79d
commit 1019672981
3 changed files with 25 additions and 3 deletions

View File

@@ -39,8 +39,12 @@ export async function runInstallationContainer(installation: Installation): Prom
HostConfig: {
RestartPolicy: { Name: "unless-stopped" },
NetworkMode: config.mcpNetworkName,
Memory: config.containerMemoryMb * 1024 * 1024,
NanoCpus: Math.round(config.containerCpus * 1e9),
// 0 disables the cap: some hosts (e.g. an unprivileged, OpenRC-based nested LXC with no
// systemd to delegate cgroup controllers) can't enforce per-container memory/CPU limits
// at all — `docker run` there fails outright trying to write memory.max. Confirmed on a
// real deploy; the outer host's own cap (if any) is the only ceiling in that case.
...(config.containerMemoryMb > 0 ? { Memory: config.containerMemoryMb * 1024 * 1024 } : {}),
...(config.containerCpus > 0 ? { NanoCpus: Math.round(config.containerCpus * 1e9) } : {}),
},
});