The machine's size on /system and in health (#12518)
A forge in a pod may use only what its cgroup allows, and that can be much
less than the host it runs on. /system, the terminal's System screen and
GET /api/v1/health report what this forge may use. They do not report the
host's whole size.
Where the limits come from
Each value is read when it is asked for:
- CPUs: cgroup v2
/sys/fs/cgroup/cpu.max,quota / period, rounded
down. The result is at least 1 and at most the host's count. A max quota,
a missing file or a malformed one means the host's count
(availableParallelism()).
- Memory: cgroup v2
/sys/fs/cgroup/memory.max. If that file is missing,
cgroup v1 /sys/fs/cgroup/memory/memory.limit_in_bytes is read instead. A
value counts only when it is a whole number below the host's memory
(totalmem()). Otherwise the host's memory is used: max, v1's huge
"unset" number, or a missing or malformed file.
cgroup v1 caveat: on cgroup v1, only the memory limit is read. The CPU
limit (cpu.cfs_quota_us / cpu.cfs_period_us) is not, so a v1 pod reports
the host's CPU count even when its quota is lower.
What each door shows
GET /api/v1/health, read by an admin: the full answer carries
machine: { cpus, memoryBytes, limitedBy }. memory.totalBytes is the
same memory limit. A signed-in reader who is not an admin, and a stranger,
get the short answer, which has no machine key.
machine.limitedByis"cgroup"when the cgroup holds the CPUs or the
memory below the host's, and "host" when both are the host's own.
/system: the summary has alimited by cgrouppill next to the core
count. The footprint's Machine fact ends with , limited by cgroup.
- The terminal's System screen: the first line reads
CPU … over N cores · limited by cgroup · load ….
When no limit is set below the host, none of these say "cgroup", and
limitedBy is "host".