Repository navigation
feat(daemon): opt-in per-seat task limit (TasksMax) on Linux/systemd hosts - #3332
Draft
billbenetti wants to merge 1 commit into
Draft
billbenetti wants to merge 1 commit into
billbenetti wants to merge 1 commit into
Conversation
…hosts Refs mvschwarz#3253. A member's `process_limits: { tasks_max: N }` (unset by default) starts that seat's pane command in a systemd user scope of its own, in openrig-seats.slice, with TasksMax=N as its only limit. systemd-run --scope execs the command, so the seat's processes are under the cap while the tmux server, the daemon and the other seats stay outside it. Without the option a seat launches exactly as before and nothing is asked of systemd. - No silent fallback: a host that can't give the seat its scope (not Linux, the daemon not a user service, the user bus not answering, systemd-run missing or refusing a throwaway scope, inherit_tmux_environment on, or a throwaway scope whose own pids.max is not the requested value) refuses the launch with code process_limits_unsupported and the reason. - New launches only: fresh launch, restore and resume read the stored value; a takeover and a handover check the host before ending the running process; restart in place of a bare pane is refused (its respawn carries no seat environment); running seats are never moved or stopped. - Status: rig seat status reads the limit back from the seat's process (requested, applied, unsupported, unknown) with pids.current and the number of forks the limit refused (pids.events max). - Only tasks_max: any other key under process_limits is refused by name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Refs #3253
Draft: a first PR for the task limit only, in the shape described in #3253 (comment). Memory and CPU limits are not in it.
What it adds
A member-level option in the rig spec, unset by default:
process_limits, a seat launches with exactly today's pane command, and nothing is asked of systemd.systemd-run --user --scope --collect --slice openrig-seats.slice -p TasksMax=N -- <today's command>.systemd-run --scopeputs itself in the new scope and then execs the command, so the pane's process and everything it forks are in that seat's scope. The tmux server stays in itsopenrig-tmux-*.scope, and the other seats, the daemon and shared pieces stay outside the cap. The seat's environment after--is the same as today: the existing reset script plus the export file.tasks_max. Any other key underprocess_limits(memory_max,cpu_quota, …) is refused by the spec validator with its name, never accepted silently.Supported hosts, and no silent fallback
A seat with
process_limitsgets its scope or is not launched.A launch is refused with code
process_limits_unsupportedand the reason when any of these is true:systemd-runis missing or refuses a throwaway scope;terminal.inherit_tmux_environmentis on;pids.max, and support counts only when that equals the requested value. This catches a user manager without the pids controller delegated, which acceptsTasksMax=with no effect.As for the server scope,
--expand-environment=noandOOMPolicy=continueare dropped only when systemd's stderr says it lacks them. A refused seat leaves the other seats unaffected.New launches, restart and resume
The limit is applied when a seat's pane process starts. Running work is never moved or stopped.
rig seat launch --fresh, restore/resume from a snapshotapplied); otherwise refused before anything is signalledrig seat launch --freshrequesteduntil thenrequestedReporting: requested, applied, unsupported, unknown
rig seat status <seat>(and/api/seat/status/:seatRefasprocessLimits) reads the limit back from the seat's pane process, never from config alone:applied: the process's cgroup is anopenrig-seat-*.scopewhosepids.maxis the requested value;requested: the seat has the option, but its process is not proven to run under it (not running, launched before the option, outside a seat scope, or a differentpids.max), with the reason;unsupported: the process is not under the limit and the host can't give a seat a user scope now (a seat already under its limit readsappliedeven when the daemon now runs where it can't make scopes);unknown: the readback failed (no pane pid, cgroup v1, unreadable files).Limit hits.
pids.eventsmaxis the number of forks the limit refused, and the status line shows it:Notes
openrig-seats.slice, so an aggregate limit an operator put on the server scope no longer covers it. The docs say so.systemd-run --userland in their own units, outside the seat's cap.rig seat stop.Tests
All tests are synthetic: fake exec and fake
/procreaders, with nothing touching the host's systemd, cgroups or tmux.packages/daemon/test/tmux-seat-process-limits.test.ts:TasksMax, and after--it is exactly today's command;systemd-run, nothing asked of systemd;process_limits_unsupportedand nonew-session, while a seat without the option still launches;launch-node-subset) and before a handover (successor-session-launcher), and the restart-in-place refusals (seat-restart-in-place: a bare pane, and a shell not read back as under the limit).process_limits.packages/cli/test/seat.test.ts).Not run here: the full suite and the real-tmux test files. On a real systemd host, the check to run is a seat at
tasks_max: Nforking past N, withpids.eventsmax> 0 and the other seats unaffected. That host proof is listed as a follow-up for this draft.