Per-exec cgroups follow-up: host-configured hard memory.max (no protobuf)

Adds an opt-in hard per-session memory ceiling on top of patch #9's scoped-OOM.
The exec already ships the full OCI Spec, so the limit rides
spec.linux.resources.memory.limit — no RPC/protobuf change:

- host framework: LinuxProcessConfiguration.memoryLimitInBytes; LinuxContainer.exec
  stamps it onto the exec spec.
- guest: Server+GRPC.createProcess reads it back and applies it as the exec
  cgroup's memory.max (new Cgroup2Manager.setMemoryMax) via createExec/ManagedProcess.
- Nucleic: ContainerServiceSettings.controlPerSessionMemoryGiB (default 0 = off),
  applied only to the shared control container (ContainerManager.exec); wired
  through ContainerEngine.exec.

So one session can't consume the whole shared container's memory before its own
(oom.group-scoped) OOM. Default off preserves #9's behavior. Compile-verified host
+ musl guest; rides the pending -nucleic2 image, still runtime-pending.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-07-13 20:12:42 -07:00
co-authored by Claude Opus 4.8
parent 2eb563c90c
commit 831d19c3a6
7 changed files with 53 additions and 8 deletions
@@ -201,7 +201,8 @@ extension ManagedContainer {
func createExec(
id: String,
stdio: HostStdio,
process: ContainerizationOCI.Process
process: ContainerizationOCI.Process,
memoryLimitBytes: UInt64? = nil // [Nucleic vendored patch] hard per-exec memory.max
) throws {
log.debug("creating exec process with \(process)")
@@ -217,6 +218,7 @@ extension ManagedContainer {
bundle: self.bundle,
owningPid: self.initProcess.pid,
execCgroupParent: self.execCgroupParent, // [Nucleic vendored patch] per-exec cgroup
execMemoryLimitBytes: memoryLimitBytes, // [Nucleic vendored patch]
log: self.log
)
self.execs[id] = process