Expand description
Helpers that translate spec.run.limits into cgroup v2 controller-file payloads.
Doctrine — D1 (no ambient defaults):
spec.run.limits.cpuMaxis the primary source for the cgroupcpu.maxcontroller value applied to the host-subprocess backend.CELLOS_CGROUP_CPU_MAXis an explicit operator override. It only applies when the spec did not setcpuMax. Setting the env var alone is not a default — operators opt in by exporting it.
These helpers are pure (no I/O, no std::env::var reads at the call sites
that exercise them in unit tests) so the resolution + normalization rules
can be tested directly without a real cgroup v2 hierarchy. The actual file
write is performed by supervisor::linux_cgroup_write_optional_controller_files.
These helpers are platform-agnostic at the type level — they operate on strings — but only the Linux subprocess path consumes their output.
Enums§
- CpuMax
Apply Outcome - Outcome of
apply_cpu_max_to_leaf— useful for tests and structured logs. - CpuMax
Source - Which source produced the
cpu.maxpayload.
Constants§
- DEFAULT_
CPU_ PERIOD_ MICROS - Default cgroup v2 CPU period when the spec omits
periodMicros. Matches the schema description (Defaults to 100000 when omitted by the runtime.) and the kernel default forcpu.max.
Functions§
- apply_
cpu_ max_ to_ leaf - Apply the resolved
cpu.maxpayload to<leaf>/cpu.max, if any. - cpu_
max_ env_ validation_ error - Whether the env override produced an unusable value. Useful for the supervisor’s warn log when the spec is silent and the env value is malformed.
- cpu_
max_ to_ write - Resolve the
cpu.maxpayload for the host-subprocess cgroup leaf.