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

@ -33,6 +33,16 @@ This document contains the help content for the `hivectl` command-line program.
* [`hivectl agents rebuild`↴](#hivectl-agents-rebuild)
* [`hivectl agents set-parent`↴](#hivectl-agents-set-parent)
* [`hivectl agents set-limits`↴](#hivectl-agents-set-limits)
* [`hivectl agents quota`↴](#hivectl-agents-quota)
* [`hivectl agents quota enable`↴](#hivectl-agents-quota-enable)
* [`hivectl agents quota show`↴](#hivectl-agents-quota-show)
* [`hivectl agents quota set`↴](#hivectl-agents-quota-set)
* [`hivectl agents subvol`↴](#hivectl-agents-subvol)
* [`hivectl agents subvol upgrade`↴](#hivectl-agents-subvol-upgrade)
* [`hivectl agents subvol snapshot`↴](#hivectl-agents-subvol-snapshot)
* [`hivectl agents subvol snapshot create`↴](#hivectl-agents-subvol-snapshot-create)
* [`hivectl agents subvol snapshot delete`↴](#hivectl-agents-subvol-snapshot-delete)
* [`hivectl agents subvol snapshot send`↴](#hivectl-agents-subvol-snapshot-send)
* [`hivectl approvals`↴](#hivectl-approvals)
* [`hivectl approvals pending`↴](#hivectl-approvals-pending)
* [`hivectl approvals approve`↴](#hivectl-approvals-approve)
@ -46,16 +56,6 @@ This document contains the help content for the `hivectl` command-line program.
* [`hivectl stop`↴](#hivectl-stop)
* [`hivectl start`↴](#hivectl-start)
* [`hivectl restart`↴](#hivectl-restart)
* [`hivectl quota`↴](#hivectl-quota)
* [`hivectl quota enable`↴](#hivectl-quota-enable)
* [`hivectl quota show`↴](#hivectl-quota-show)
* [`hivectl quota limit`↴](#hivectl-quota-limit)
* [`hivectl subvol`↴](#hivectl-subvol)
* [`hivectl subvol upgrade`↴](#hivectl-subvol-upgrade)
* [`hivectl subvol snapshot`↴](#hivectl-subvol-snapshot)
* [`hivectl subvol snapshot create`↴](#hivectl-subvol-snapshot-create)
* [`hivectl subvol snapshot delete`↴](#hivectl-subvol-snapshot-delete)
* [`hivectl subvol snapshot send`↴](#hivectl-subvol-snapshot-send)
* [`hivectl open`↴](#hivectl-open)
* [`hivectl completions`↴](#hivectl-completions)
@ -79,8 +79,6 @@ Sibling to the `hive-c0re` daemon binary. Covers host-side admin operations that
* `stop` — Stop containers hive-wide in one operator action
* `start` — Start containers hive-wide — the inverse of `hivectl stop`
* `restart` — Restart containers hive-wide — `stop` then `start` over one scope
* `quota` — Per-agent disk accounting + optional quotas via btrfs qgroups
* `subvol` — btrfs subvolume management for agent state dirs
* `open` — Print (and best-effort open in a browser) a hive web surface URL
* `completions` — Generate a shell completion script for `hivectl` and print it to stdout
@ -351,6 +349,8 @@ Lifecycle actions on managed agent containers. Needs the hive-c0re daemon runnin
* `rebuild` — Apply pending config to a managed container
* `set-parent` — Move an agent in the topology tree — under a new parent, or to root
* `set-limits` — Declare an agent's CPU/memory limits, overriding the hive-wide defaults
* `quota` — Per-agent disk accounting + optional quotas via btrfs qgroups
* `subvol` — btrfs subvolume management for agent state dirs
@ -507,7 +507,7 @@ Move an agent in the topology tree — under a new parent, or to root
Declare an agent's CPU/memory limits, overriding the hive-wide defaults.
Replaces the agent's whole override entry rather than merging into it: any limit you don't pass returns to the hive-wide default. To change one and keep the other, pass both.
Replaces the agent's whole override entry rather than merging into it: any limit you don't pass returns to the hive-wide default. To change one and keep the other, pass both. Disk is a separate resource with its own group — see `agents quota`.
**Usage:** `hivectl agents set-limits [OPTIONS] <NAME>`
@ -523,6 +523,153 @@ Replaces the agent's whole override entry rather than merging into it: any limit
## `hivectl agents quota`
Per-agent disk accounting + optional quotas via btrfs qgroups.
Opt-in: enable qgroup accounting, then report per-agent usage or cap an agent. No-op on non-btrfs hosts.
**Usage:** `hivectl agents quota <COMMAND>`
###### **Subcommands:**
* `enable` — Enable btrfs qgroup accounting on the agent-state filesystem
* `show` — Report per-agent disk usage from btrfs qgroups (all agents, or one by name)
* `set` — Set or clear an agent's disk-usage quota
## `hivectl agents quota enable`
Enable btrfs qgroup accounting on the agent-state filesystem.
Run once before `show` / `limit`. No-op on non-btrfs hosts.
**Usage:** `hivectl agents quota enable`
## `hivectl agents quota show`
Report per-agent disk usage from btrfs qgroups (all agents, or one by name)
**Usage:** `hivectl agents quota show [NAME]`
###### **Arguments:**
* `<NAME>` — Agent to show (omit for all agents with a state subvolume)
## `hivectl agents quota set`
Set or clear an agent's disk-usage quota.
Named `set` rather than `set-quota` because the enclosing `quota` group already carries the noun — `agents quota set iris 5G`. The `set-<noun>` spelling stays for the flat verbs (`set-parent`, `set-limits`), which have no group to inherit it from.
**Usage:** `hivectl agents quota set <NAME> <SIZE>`
###### **Arguments:**
* `<NAME>` — Agent whose state subvolume to limit
* `<SIZE>` — Size cap (`5G`, `500M`, `1073741824`) or `none` to clear
## `hivectl agents subvol`
btrfs subvolume management for agent state dirs.
Upgrade an existing plain-dir agent's state into a btrfs subvolume so it gains snapshots and per-subvol usage/quota.
**Usage:** `hivectl agents subvol <COMMAND>`
###### **Subcommands:**
* `upgrade` — Convert a plain-dir agent state root into a btrfs subvolume in place, so it gains snapshots and per-subvol usage/quota
* `snapshot` — Read-only snapshots of an agent's state subvolume
## `hivectl agents subvol upgrade`
Convert a plain-dir agent state root into a btrfs subvolume in place, so it gains snapshots and per-subvol usage/quota.
Bounces the agent to migrate its state, so it requires `--yes`.
**Usage:** `hivectl agents subvol upgrade [OPTIONS] <NAME>`
###### **Arguments:**
* `<NAME>` — Agent name (e.g. `damocles`, `iris`)
###### **Options:**
* `--yes` — Confirm: this stops the agent, migrates its state dir, and restarts it. Required — the command refuses without it
## `hivectl agents subvol snapshot`
Read-only snapshots of an agent's state subvolume
**Usage:** `hivectl agents subvol snapshot <COMMAND>`
###### **Subcommands:**
* `create` — Create a read-only snapshot (agent must already be a subvolume)
* `delete` — Delete a snapshot created by `subvol snapshot create`
* `send` — Export a snapshot to a local file via `btrfs send` (the local-file half of inter-hive migration transport; the cross-hive `ssh ... btrfs receive` leg isn't wired up yet). Also useful standalone as a point-in-time backup: a full send with no `--parent` produces a self-contained archive of the snapshot
## `hivectl agents subvol snapshot create`
Create a read-only snapshot (agent must already be a subvolume)
**Usage:** `hivectl agents subvol snapshot create --label <LABEL> <NAME>`
###### **Arguments:**
* `<NAME>` — Agent name (e.g. `damocles`, `iris`)
###### **Options:**
* `--label <LABEL>` — Snapshot label. Mandatory, and must start with `hive-` — the prefix doubles as an allow-list hive-priv checks so only hivectl-issued snapshot names can reach the `btrfs subvolume snapshot` shellout
## `hivectl agents subvol snapshot delete`
Delete a snapshot created by `subvol snapshot create`
**Usage:** `hivectl agents subvol snapshot delete <NAME> <LABEL>`
###### **Arguments:**
* `<NAME>` — Agent name the snapshot belongs to
* `<LABEL>` — Snapshot label passed to `subvol snapshot create --label`
## `hivectl agents subvol snapshot send`
Export a snapshot to a local file via `btrfs send` (the local-file half of inter-hive migration transport; the cross-hive `ssh ... btrfs receive` leg isn't wired up yet). Also useful standalone as a point-in-time backup: a full send with no `--parent` produces a self-contained archive of the snapshot
**Usage:** `hivectl agents subvol snapshot send [OPTIONS] --dest <DEST> <NAME> <LABEL>`
###### **Arguments:**
* `<NAME>` — Agent name the snapshot belongs to
* `<LABEL>` — Snapshot label passed to `subvol snapshot create --label`
###### **Options:**
* `--parent <PARENT>` — Optional parent snapshot label for an incremental send (`btrfs send -p`) — must be an existing, older snapshot of the same agent. Omit for a full send
* `--dest <DEST>` — Destination filename (not a path) under the migrate-staging dir. Refused if it already exists
## `hivectl approvals`
Operator approval queue: list, approve, or deny pending requests.
@ -719,151 +866,6 @@ Bare `hivectl restart` restarts everything; scope flags narrow it.
## `hivectl quota`
Per-agent disk accounting + optional quotas via btrfs qgroups.
Opt-in: enable qgroup accounting, then report per-agent usage or cap an agent. No-op on non-btrfs hosts.
**Usage:** `hivectl quota <COMMAND>`
###### **Subcommands:**
* `enable` — Enable btrfs qgroup accounting on the agent-state filesystem
* `show` — Report per-agent disk usage from btrfs qgroups (all agents, or one by name)
* `limit` — Set or clear an agent's disk-usage quota
## `hivectl quota enable`
Enable btrfs qgroup accounting on the agent-state filesystem.
Run once before `show` / `limit`. No-op on non-btrfs hosts.
**Usage:** `hivectl quota enable`
## `hivectl quota show`
Report per-agent disk usage from btrfs qgroups (all agents, or one by name)
**Usage:** `hivectl quota show [NAME]`
###### **Arguments:**
* `<NAME>` — Agent to show (omit for all agents with a state subvolume)
## `hivectl quota limit`
Set or clear an agent's disk-usage quota
**Usage:** `hivectl quota limit <NAME> <SIZE>`
###### **Arguments:**
* `<NAME>` — Agent whose state subvolume to limit
* `<SIZE>` — Size cap (`5G`, `500M`, `1073741824`) or `none` to clear
## `hivectl subvol`
btrfs subvolume management for agent state dirs.
Upgrade an existing plain-dir agent's state into a btrfs subvolume so it gains snapshots and per-subvol usage/quota.
**Usage:** `hivectl subvol <COMMAND>`
###### **Subcommands:**
* `upgrade` — Convert a plain-dir agent state root into a btrfs subvolume in place, so it gains snapshots and per-subvol usage/quota
* `snapshot` — Read-only snapshots of an agent's state subvolume
## `hivectl subvol upgrade`
Convert a plain-dir agent state root into a btrfs subvolume in place, so it gains snapshots and per-subvol usage/quota.
Bounces the agent to migrate its state, so it requires `--yes`.
**Usage:** `hivectl subvol upgrade [OPTIONS] <NAME>`
###### **Arguments:**
* `<NAME>` — Agent name (e.g. `damocles`, `iris`)
###### **Options:**
* `--yes` — Confirm: this stops the agent, migrates its state dir, and restarts it. Required — the command refuses without it
## `hivectl subvol snapshot`
Read-only snapshots of an agent's state subvolume
**Usage:** `hivectl subvol snapshot <COMMAND>`
###### **Subcommands:**
* `create` — Create a read-only snapshot (agent must already be a subvolume)
* `delete` — Delete a snapshot created by `subvol snapshot create`
* `send` — Export a snapshot to a local file via `btrfs send` (the local-file half of inter-hive migration transport; the cross-hive `ssh ... btrfs receive` leg isn't wired up yet). Also useful standalone as a point-in-time backup: a full send with no `--parent` produces a self-contained archive of the snapshot
## `hivectl subvol snapshot create`
Create a read-only snapshot (agent must already be a subvolume)
**Usage:** `hivectl subvol snapshot create --label <LABEL> <NAME>`
###### **Arguments:**
* `<NAME>` — Agent name (e.g. `damocles`, `iris`)
###### **Options:**
* `--label <LABEL>` — Snapshot label. Mandatory, and must start with `hive-` — the prefix doubles as an allow-list hive-priv checks so only hivectl-issued snapshot names can reach the `btrfs subvolume snapshot` shellout
## `hivectl subvol snapshot delete`
Delete a snapshot created by `subvol snapshot create`
**Usage:** `hivectl subvol snapshot delete <NAME> <LABEL>`
###### **Arguments:**
* `<NAME>` — Agent name the snapshot belongs to
* `<LABEL>` — Snapshot label passed to `subvol snapshot create --label`
## `hivectl subvol snapshot send`
Export a snapshot to a local file via `btrfs send` (the local-file half of inter-hive migration transport; the cross-hive `ssh ... btrfs receive` leg isn't wired up yet). Also useful standalone as a point-in-time backup: a full send with no `--parent` produces a self-contained archive of the snapshot
**Usage:** `hivectl subvol snapshot send [OPTIONS] --dest <DEST> <NAME> <LABEL>`
###### **Arguments:**
* `<NAME>` — Agent name the snapshot belongs to
* `<LABEL>` — Snapshot label passed to `subvol snapshot create --label`
###### **Options:**
* `--parent <PARENT>` — Optional parent snapshot label for an incremental send (`btrfs send -p`) — must be an existing, older snapshot of the same agent. Omit for a full send
* `--dest <DEST>` — Destination filename (not a path) under the migrate-staging dir. Refused if it already exists
## `hivectl open`
Print (and best-effort open in a browser) a hive web surface URL.