87 lines
5.5 KiB
Markdown
87 lines
5.5 KiB
Markdown
# Private build control portal
|
|
|
|
Standalone Python stdlib service. No ingress, reverse proxy, Docker socket or
|
|
public-site route. The service binds **only** configured LAN/Tailscale/loopback
|
|
addresses, checks the peer subnet and Host header, and requires same-origin JSON
|
|
POSTs for the fixed systemd start/stop/schedule actions. It trusts users on those
|
|
private networks; it is a personal control surface, not an Internet-facing app.
|
|
|
|
Terra deployment: `192.168.88.104:8099`, `100.64.0.11:8099`, `127.0.0.1:8099`.
|
|
Allowed peers: `192.168.88.0/24`, `100.64.0.0/10`, `127.0.0.0/8`.
|
|
Config `/etc/archipelago/control.json` includes `listen`, `hosts` (with port),
|
|
`allowed_networks`, `port`, `coordinator_root`, `worker_root`, `worker_source_root`
|
|
and optionally `snapshot_dataset` (default `tank/archipelago/archlinux`) plus
|
|
`snapshot_command` (default `/usr/local/sbin/archipelago-mirror-snapshot`) and
|
|
`snapshot_verify_url` (public base URL such as `https://mirror.nw-sys.ru/archipelago`;
|
|
a pinned date must answer 200 for `core/os/x86_64/core.db`, otherwise the start is
|
|
refused instead of failing inside the first package download).
|
|
Unit: `deploy/archipelago-control.service`. Source: `/opt/archipelago/control-source`,
|
|
which must contain `control/` and the imported `pipeline/monitor.py` and
|
|
`pipeline/release-schedule.py` (deploy the `pipeline/` directory with `control/`).
|
|
LAN address changes require updating bind/Host config and restarting this service.
|
|
|
|
## Monitoring contract
|
|
|
|
- `/api/status`: actual systemd service/timer state, next trigger, history, source SHAs
|
|
and the immutable repository snapshots (`snapshots`), read from the ZFS dataset.
|
|
- `/api/run?run=ID`: ordered phase events, all invoked actions, complete argv,
|
|
start/end times, elapsed time, exit code/error, and inventory of nested logs.
|
|
- `/api/log?run=ID&id=LOG&offset=BYTE`: 256-KiB pages from any byte offset;
|
|
offset -1 tails. Every byte is reachable; the UI does not equate a tail to a full log.
|
|
- `download=1`: stream the complete file, without a size cap. No arbitrary path API.
|
|
- All output is rendered as text; log content never becomes HTML or executable code.
|
|
- Old runs expose all surviving logs but explicitly lack the new action timeline.
|
|
- Progress is measured phases/status/duration, not an invented overall percentage.
|
|
|
|
New runs retain `action-NNNN.log` (stdout + stderr, no line limit), command metadata,
|
|
phase events and nested CLI/build/acceptance/serial/Flatpak logs on ZFS under
|
|
`/opt/archipelago/data/private/pipeline-monitor/ID`. Coordinator journald output is
|
|
also available by invocation ID. The worker's live files are available before archive.
|
|
Log history is separate from artifact-retention cleanup and is **not auto-deleted**.
|
|
Source revisions are frozen into each run's source archive; the overview shows the
|
|
next run's configured source revisions. Native executable logs retain their existing
|
|
format; monitoring does not substitute human CLI output for private detailed logs.
|
|
|
|
Stopping the driver stops owned worker units, retains logs, and leaves unfinished
|
|
build artifacts for diagnosis rather than starting a lengthy archive. D-098 removed
|
|
the VM phases, so the portal no longer stops VM units. No command shell or arbitrary
|
|
service name is accepted over HTTP.
|
|
|
|
## Manual build request
|
|
|
|
`POST /api/control` accepts `{action, mode, snapshot}`: `mode` is `iso` or `ostree`,
|
|
`snapshot` is `latest`, `new` or an existing `YYYY-MM-DD` date. Before the unit
|
|
starts, the portal resolves the choice to one immutable date and writes
|
|
`/opt/archipelago/data/private/release-cycle/cycle-request.json`; the driver consumes
|
|
that file exactly once (ignoring a request older than 900 s) and binds the run to
|
|
that snapshot URL. A scheduled or resumed run therefore never inherits a manual
|
|
build's inputs.
|
|
|
|
`new` creates a snapshot through a transient `systemd-run` unit, because the
|
|
read-only view it bind-mounts must land in the host mount namespace to be published
|
|
over HTTP; a mount made inside this unit's own namespace would be invisible to the
|
|
web server. The mount script then publishes the verified list to
|
|
`data/private/release-cycle/snapshots.json` (each date checked against its Core
|
|
database in the published view), and the portal lists and validates from that
|
|
manifest — neither this unit's private namespace nor ZFS `.zfs/snapshot` traversal is
|
|
a reliable source here. Retention keeps at most three monthly snapshots and prunes
|
|
the orphaned views (`deploy/mirror-snapshot*.sh`).
|
|
|
|
A mounted host view is not yet a downloadable URL: the container that serves
|
|
`/archipelago/` keeps the mount view it started with unless its bind propagates
|
|
(`compose.yaml` asks for `bind.propagation: rslave`). The mount script verifies the
|
|
dates from inside that container, restarts it once when it still has a stale view and
|
|
drops a date it cannot serve; the portal additionally requires the pinned date to
|
|
answer HTTP 200 before it writes the request.
|
|
|
|
`{action: "start", "resume": true}` continues the last failed run under the same
|
|
service unit: the request carries only `resume` and `requested_at`, so the run keeps
|
|
the mode and the immutable snapshot it was pinned to, and the stop button and the
|
|
status view keep describing the unit that is actually running.
|
|
|
|
Schedule buttons enable or disable the monthly dispatcher timer; the cadence itself
|
|
(1st of the month, ISO + OSTree) is fixed by the code and is not editable from the
|
|
portal.
|
|
|
|
Runtime API tests: `python3 tests/control_portal.py` on terra. They use a temporary
|
|
fixture and fake systemd responses; they never start or stop a real build.
|