SCHED-957: isolate Docker containers from slurmd cgroup to prevent pod OOM kills#2268
Draft
SCHED-957: isolate Docker containers from slurmd cgroup to prevent pod OOM kills#2268
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Creates an isolated cgroup for Docker containers spawned inside Slurm jobs to prevent Docker memory usage from accumulating in the pod-level cgroup and triggering kubelet OOM kills that take down slurmd.
Changes:
- Inject
REAL_MEMORY(MiB) into the slurmd container environment for cgroup memory sizing. - At worker startup, create a dedicated
docker/cgroup sibling and set itsmemory.maxbased onREAL_MEMORY. - Extend the
/usr/bin/dockerwrapper to inject--cgroup-parentso new containers are created under the dedicated Docker cgroup.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/render/worker/container.go | Exposes REAL_MEMORY env var to the slurmd container based on rendered resource requests. |
| internal/consts/cgroup.go | Adds EnvRealMemory constant used for the new env var name. |
| images/worker/supervisord_entrypoint.sh | Creates /sys/fs/cgroup/.../docker and configures memory.max; persists cgroup parent path for the docker wrapper. |
| ansible/roles/docker-cli/files/docker.sh | Injects --cgroup-parent into docker run/create calls based on /run/docker-cgroup-parent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a user runs Docker inside a Slurm job, Docker containers are spawned by
dockerdas its own children and inheritdockerd's cgroup -which is the pod-level cgroup, not the Slurm job cgroup. As a result:memory.maxconstraintslurmd,sshd, anddockerdslurmddown with itSolution
A single dedicated Docker cgroup is created once at pod startup (in
supervisord_entrypoint.sh) as a sibling of the main container cgroup:Pod cgroup (K8s limit, e.g. 1600G)
├── / ← slurmd, dockerd, sshd (unaffected by Docker OOMs)
└── docker/ ← ALL Docker containers from ALL jobs
memory.max = REAL_MEMORY
memory.maxon the Docker cgroup is set toREAL_MEMORY(in MiB) — the node's allocatable memory as configured in Slurm. This ensures Docker containers are OOM-killed at the job allocation boundary before the pod-level limit is reached, leavingslurmdwith its intended headroom.The existing
docker.shwrapper (installed as/usr/bin/dockerTesting
Release Notes
Fix: Docker containers launched inside Slurm jobs are now placed in a dedicated isolated cgroup (
docker/) withmemory.maxset to the node'sREAL_MEMORYvalue. This prevents Docker workload memory from causing pod-level OOM kills andslurmdrestarts.