refactor(hivectl): move quota + subvol under agents

Both groups only ever act on a single managed agent's state dir, so
they belong in the `agents` namespace rather than as top-level verbs
next to `forge` / `matrix` / `wg`.

Renames `quota limit` -> `quota set`: the enclosing group already
carries the noun, so the bare verb matches the flat `set-parent` /
`set-limits` spelling without stuttering, and it removes the
`set-limits` (cpu/mem) vs `quota limit` (disk) ambiguity. Adds a
cross-pointer from `set-limits` to `agents quota`.

Handlers stay in their own modules; `run_agents` gains the reparenting
glue. Regenerates docs/tools/hivectl-cli.md.

Refs #2724
This commit is contained in:
atlas 2026-07-26 18:15:42 +02:00 committed by mara
commit 766b1f71fb
9 changed files with 215 additions and 204 deletions

View file

@ -290,12 +290,12 @@ pub enum HostRequest {
/// the agent's `gh` wrapper / git credential helper — no rebuild needed.
SetAgentGithubToken { agent: Ident, token: String },
/// Turn on btrfs qgroup accounting on the agent-state filesystem, via
/// the privileged helper. Daemon-side equivalent of `hivectl quota
/// the privileged helper. Daemon-side equivalent of `hivectl agents quota
/// enable`. Returns advisory lines in [`HostResponse::messages`].
QuotaEnable,
/// Set (or, with `limit = None`, clear) an agent's btrfs disk quota via
/// the privileged helper. Daemon-side equivalent of `hivectl quota
/// limit`; the size string is parsed to bytes client-side. Returns a
/// the privileged helper. Daemon-side equivalent of `hivectl agents quota
/// set`; the size string is parsed to bytes client-side. Returns a
/// bare success — the client prints the confirmation from the value it
/// sent.
QuotaLimit {
@ -303,7 +303,7 @@ pub enum HostRequest {
#[serde(default)]
limit: Option<u64>,
},
/// Report per-agent btrfs qgroup usage (`hivectl quota show [name]`).
/// Report per-agent btrfs qgroup usage (`hivectl agents quota show [name]`).
/// The daemon resolves the agent set (all kept state dirs when `name`
/// is absent) and reads each subvolume's referenced/exclusive usage via
/// the privileged helper. Result rows land in [`HostResponse::quota`];
@ -314,19 +314,19 @@ pub enum HostRequest {
name: Option<Ident>,
},
/// Migrate an agent's plain state dir to a btrfs subvolume via the
/// privileged helper (`hivectl subvol upgrade`). The agent MUST already
/// privileged helper (`hivectl agents subvol upgrade`). The agent MUST already
/// be stopped — the client orchestrates stop → this → start. Returns a
/// bare success; the client prints its own progress lines.
UpgradeSubvolume { name: Ident },
/// Create a read-only btrfs snapshot of an agent's state subvolume
/// (`hivectl subvol snapshot create`). `label` is validated client-side
/// (`hivectl agents subvol snapshot create`). `label` is validated client-side
/// AND by hive-priv. Returns the snapshot's host path in
/// [`HostResponse::messages`].
SnapshotSubvolume { name: Ident, label: String },
/// Delete a snapshot created by `SnapshotSubvolume` (`hivectl subvol
/// Delete a snapshot created by `SnapshotSubvolume` (`hivectl agents subvol
/// snapshot delete`). Bare success; the client prints the confirmation.
DeleteSnapshot { name: Ident, label: String },
/// Export a snapshot to a local file via `btrfs send` (`hivectl subvol
/// Export a snapshot to a local file via `btrfs send` (`hivectl agents subvol
/// snapshot send`). `dest` is a bare filename (hive-priv rejects paths);
/// `parent` names an optional parent snapshot for an incremental send.
/// Returns the written file's host path in [`HostResponse::messages`].