container stats: measure agent disk usage through hive-priv, unknown on failure
The disk sampler ran `du -sxb` as the unprivileged hive-core user over
each agent's state/, work/ and container rootfs. hive-core cannot read
the rootfs or all of the agent-owned files, so `du` failed and each
failed path silently counted as 0: the dashboard showed a few MB for
agents using over 13 GB.
Add a hive-priv `MeasureAgentDisk { agent_name }` op. hive-priv
validates the name, derives the three paths itself (the request carries
no path), skips the ones that don't exist, and runs one
`du -s -x -b -c -P` as root with a 10 min timeout. A timeout, a non-zero
exit or output without a `total` line is an error.
hive-c0re calls it every 30 min instead of running `du` every 5 min:
each pass walks every agent's full tree as root on the disk the agents
work on, and the sizes move slowly. A failed measurement is cached as
None, so `disk_bytes` is null, the OTel storage.usage sample is omitted
and the dashboard shows "unknown", never 0.
`Coordinator::agent_work_dir` had no other caller and is removed.
Closes #4956
This commit is contained in:
parent
8ffceea8e3
commit
98ccc31e2b
10 changed files with 244 additions and 179 deletions
|
|
@ -557,6 +557,23 @@ pub enum PrivRequest {
|
|||
limit_bytes: Option<u64>,
|
||||
},
|
||||
|
||||
// --- Agent disk usage ---
|
||||
/// Measure an agent's on-disk footprint with one bounded
|
||||
/// `du -s -x -b -c -P` over its `<AGENT_STATE_ROOT>/<agent_name>/state`
|
||||
/// and `…/work` dirs and its container rootfs
|
||||
/// (`/var/lib/nixos-containers/h-<agent_name>`). Returns the total in
|
||||
/// bytes as a decimal string in `stdout`.
|
||||
///
|
||||
/// hive-priv derives all three paths from `agent_name`; the request
|
||||
/// carries no path. A path that doesn't exist is skipped. A timeout, a
|
||||
/// non-zero `du` exit or unparseable output is an error, never a partial
|
||||
/// or zero total. Requires root: `hive-core` cannot read the rootfs or
|
||||
/// the agent-owned files under `state/` and `work/`.
|
||||
MeasureAgentDisk {
|
||||
/// Logical agent name (validated by `validate_agent_name`).
|
||||
agent_name: String,
|
||||
},
|
||||
|
||||
/// Convert an existing **plain-directory** agent state root into a btrfs
|
||||
/// subvolume in place. The operator opt-in counterpart to the progressive
|
||||
/// `EnsureAgentSubvolume` (which only ever makes *new* agents subvolumes):
|
||||
|
|
|
|||
Loading…
Reference in a new issue