[Nix#9675] nix creates processes in cgroup inner nodes #77
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
Feature/S3
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#77
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Upstream-Issue: NixOS/nix#9675
Describe the bug
I run a shared build cluster at my company. I'm trying to limit my system's resource utilisation such that one rogue derivation cannot take out a build node. I'm trying to use the Nix cgroup support to help achieve this.
What I had envisaged was watching for new Nix build cgroups being created, and then setting memory limits on them such that memory leaks lead to killed processes.
Unfortunately, this is hard to implement because Nix creates the cgroups as children of the cgroup of the nix-daemon's cgroup.
This is not a recommended configuration with cgroupsv2 as here, inner nodes are not allowed to contain processes.
While the nix-daemon process lives in the parent cgroup, Linux does not allow any controls to be set on any of the child cgroups (limiting their utility considerably!).
The systemd docs say the below:
https://systemd.io/CGROUP_DELEGATION/
Nix is basically doing this, but forgot 'you have to move your main daemon process out of that cgroup' bit.
Expected behavior
Nix creates its build cgroups parented by a cgroup which does not contain processes.
nix-env --version
outputAll Nix releases that support cgroups at time of writing.
Additional context
My workaround for now was to change the nix-daemon's unit to launch in the root cgroup, as this has no such limitation (execstart cgexec -g ":/" nix-daemon). Then, a combination of inotifywait (on /nix/var/nix/cgroups) to figure out what cgroups matter, xargs, and a bash function which resolves that link to find the cgroup dir and sets the properties is all we need :).
Priorities
Add 👍 to issues you find important.