@astrofoundry/pi-astro 0.40.8 → 0.40.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/arcane/SKILL.md +1 -0
- package/specialists/AGENTS.md +2 -2
- package/specialists/README.md +1 -1
- package/specialists/entry/remote/spc-arcane-op.py +83 -0
- package/specialists/lib/arcane-host.test.ts +2 -0
- package/specialists/lib/arcane-host.ts +1 -0
- package/specialists/lib/stack-update.test.ts +5 -0
- package/specialists/lib/stack-update.ts +4 -2
package/package.json
CHANGED
package/skills/arcane/SKILL.md
CHANGED
|
@@ -86,6 +86,7 @@ The usual trigger is the owner's **Upgrade Arcane** button under the Arcane Dail
|
|
|
86
86
|
- `service-check grimoire|mealie` (guest-local endpoints), `crawl4ai-info`, `recyclarr-naming`, `arcane-version`, `queue-callback`, `bazarr-providers`, `mealie-api`, `queue-job <uuid>`, `object-stat grimoire <path>`.
|
|
87
87
|
- `radarr-movie <tt…> [command-id]` and `radarr-interface` read Radarr's key from its host config; each needs an owner's approval.
|
|
88
88
|
- `db-list mealie|paperless`, `db-dump mealie|paperless` (gzip pg_dump into `/var/backups/spc-arcane/<stack>/<UTC>`, checked, with row counts), `db-restore <stack> <stamp>` (owner approval): fills an **empty** database from one of those dumps, the app container stopped meanwhile. It refuses a database that holds tables; emptying one is an operator decision. Dumps are never deleted by the tool; `db-list` names those beyond the last three in `over_keep`.
|
|
89
|
+
- `supabase-backup`: the backup `supabase/AGENTS.md` asks for before a Supabase change. It writes custom-format dumps of `postgres` and `_supabase`, `globals.sql`, and `db-config.tar.gz` (the pgsodium root key) into `/var/backups/supabase-upgrades/<UTC>`, checks each dump with pg_restore's listing and full decoding, and prints the manifest with the image's repo digests (record them as the rollback digest). It refuses when the disk has less free space than the databases. Restoring stays an operator step.
|
|
89
90
|
|
|
90
91
|
Public routes (Supabase, Grimoire, Mealie URLs) are `astro.edge`'s `route-probe`, run from Cortex.
|
|
91
92
|
|
package/specialists/AGENTS.md
CHANGED
|
@@ -57,8 +57,8 @@ Wrappers ship as TypeScript and run under Node 24 type stripping: erasable synta
|
|
|
57
57
|
- `entry/specialist-install.sh` runs as root, so it runs only `/usr/bin`, `/bin`, `/usr/sbin`, `/sbin` and the Node it installed, never Homebrew or anything else the main user can write; it checks that `/usr/local/libexec/specialist-node` (and each `specialist-<tool>` folder) and its parents belong to root and are writable by nobody else. Arguments are checked before the root test (tests exercise that part). Downloads go to a root-only temporary directory and are verified before use: Node against `SHASUMS256.txt` and the LTS flag in `index.json`, npm tarballs against the registry's `sha512` integrity, arcane-cli against the release's checksums file. Inside `/Users/specialist` it works only as `specialist` (`sudo -u specialist -H`), from a staging directory root hands over, so a link the specialist plants cannot redirect a root write. Each component switches by rename after a check (every installed wrapper's `--help`, `--version` of the new binary) and restores the previous copy when the check fails. Older versions are refused; `rollback` swaps current and previous. `python`, `gcloud`, `bw`, and `jq` follow the same rules: version folders under `/usr/local/libexec/specialist-<tool>/` behind the links `current` and `previous`, sealed `root:wheel` and not writable by others, smoke-tested as `specialist` before `current` moves; `python` refuses a switch that breaks the current gcloud. Consumers use the `current` paths: `provision.sh` for `bw` and `jq`, `edge.json` for `gcloud` and `gcloudPython`. Nothing a wrapper runs with secrets may come from Homebrew.
|
|
58
58
|
- `main()` waits for stdout and stderr to flush before `process.exit`: on a pipe, exiting right after a write drops everything past the 64 KiB buffer, which cut large answers such as `projects list --all` until 2026-09-25 (`lib/flush.test.ts`).
|
|
59
59
|
- `arcane update-report [--all]` is `lib/image-updates.ts` over `lib/registry.ts`: a fresh `images updates check --all`, then `projects list --all` for the stack and service of each image reference, then the registries' tag lists and manifest digests (anonymous bearer tokens from each registry's challenge; digests by HEAD, which Docker Hub does not count as a pull; lscr.io is read from ghcr.io). A floating or major-series tag is resolved to the release tag whose digest matches the running and the latest build, searching the newest tags of the three commonest release shapes; a fixed tag is compared with the newest tag of the same shape; a digest pin with the newest release. Checks older than one minute before the run count as stale and show as unknown. Private images (anonymous access refused with 401 or 403) are excluded from rows, counts, and table, listed in `privateImages`, and counted in the summary line. The table is fixed-width text for a code block, because Discord renders no Markdown tables. The answer adds `holds` from `update-holds.json` at origin's branch head (`git show`, no working-tree read), or `holdsError` when that file is malformed.
|
|
60
|
-
- `arcane stack-update <stack> [--confirm]` (`lib/stack-update.ts` for the pure parts) is deterministic: refuses `arcane`, held stacks (the checkout's `update-holds.json` after `pull --ff-only`; a malformed file is an error), a dirty or ahead checkout, stopped stacks, and an update across a major version without `--confirm` (which the gate turns into an owner approval). Pending rows come from a fresh per-image check resolved like `update-report`. `edit tag`/`edit digest` rows rewrite `image:` lines that name exactly the old reference (`replaceImageRef`, quoted or not, trailing comment kept) in the sync's `composePath`, then commit, push, and wait for `gitops list` to report success at that commit (20 min, polled every 30 s). Then `projects redeploy <stack> --yes` (35 min), container checks through `containers list --all` and `containers get` (`composeInfo.projectName`, health; 5 min, polled every 15 s), and a fresh check that each service is current. A failure after a commit reverts, pushes, waits for the sync, redeploys, and checks again (`rolled back`); a pull-only failure stays `failed`. Every outcome prints JSON with `status` and exits 0. Worst case about 125 minutes, so the gate's `timeoutMs` for arcane must exceed it (8,100,000). The checkout is not locked, so an agent call and a bridge click at the same time can collide on it; the bridge runs one Arcane update at a time.
|
|
61
|
-
- `arcane host <command>` runs over the forced-command key of user `spc-arcane` on VM 100. `HOST_COMMANDS` in `lib/arcane-host.ts` must list exactly the operations of `entry/remote/spc-arcane-op.py` (a test compares them); the tracked copies live in the arcane repository's `host/` (`spc-arcane-host-entry`, `spc-arcane-op`, `spc-arcane-sudoers`, `spc-arcane-install.sh`) with the probes in `host/spc-arcane-probes/`. The entry only splits words (letters, digits, space, `._:/+-`) and hands them to `sudo -n /usr/local/sbin/spc-arcane-op`, the one command its sudoers line allows; the op checks the name and every argument and runs the reviewed arcane-ops probes, which print only allowlisted fields. Manager steps (`manager-*`) are internal to `manager-upgrade`/`manager-rollback` and refused through `host`. Nothing on the host deletes data: a manager rollback restores the image and Compose file, not the data volume (R3 stays manual), `db-restore` only fills an empty database, and dumps are never pruned by the tool. `host-audit` compares the host's hashes with `host/<name>` of the `arcane-gitops` checkout after a pull.
|
|
60
|
+
- `arcane stack-update <stack> [--confirm]` (`lib/stack-update.ts` for the pure parts) is deterministic: refuses `arcane`, held stacks (the checkout's `update-holds.json` after `pull --ff-only`; a malformed file is an error), a dirty or ahead checkout, stopped stacks, and an update across a major version without `--confirm` (which the gate turns into an owner approval). Pending rows come from a fresh per-image check resolved like `update-report`. `edit tag`/`edit digest` rows rewrite `image:` lines that name exactly the old reference (`replaceImageRef`, quoted or not, trailing comment kept) in the sync's `composePath`, then commit, push, and wait for `gitops list` to report success at that commit (20 min, polled every 30 s). Then `projects redeploy <stack> --yes` (35 min), container checks through `containers list --all` and `containers get` (`composeInfo.projectName`, health; 5 min, polled every 15 s; a job that exited with code 0 counts as done whatever health its image's inherited check left, as bigcapital's migration did on 2026-10-28), and a fresh check that each service is current. A failure after a commit reverts, pushes, waits for the sync, redeploys, and checks again (`rolled back`); a pull-only failure stays `failed`. Every outcome prints JSON with `status` and exits 0. Worst case about 125 minutes, so the gate's `timeoutMs` for arcane must exceed it (8,100,000). The checkout is not locked, so an agent call and a bridge click at the same time can collide on it; the bridge runs one Arcane update at a time.
|
|
61
|
+
- `arcane host <command>` runs over the forced-command key of user `spc-arcane` on VM 100. `HOST_COMMANDS` in `lib/arcane-host.ts` must list exactly the operations of `entry/remote/spc-arcane-op.py` (a test compares them); the tracked copies live in the arcane repository's `host/` (`spc-arcane-host-entry`, `spc-arcane-op`, `spc-arcane-sudoers`, `spc-arcane-install.sh`) with the probes in `host/spc-arcane-probes/`. The entry only splits words (letters, digits, space, `._:/+-`) and hands them to `sudo -n /usr/local/sbin/spc-arcane-op`, the one command its sudoers line allows; the op checks the name and every argument and runs the reviewed arcane-ops probes, which print only allowlisted fields. Manager steps (`manager-*`) are internal to `manager-upgrade`/`manager-rollback` and refused through `host`. Nothing on the host deletes data: a manager rollback restores the image and Compose file, not the data volume (R3 stays manual), `db-restore` only fills an empty database, and dumps are never pruned by the tool. `supabase-backup` writes the pre-change backup of `supabase/AGENTS.md` (both databases with `pg_dump -Fc`, each listed and fully decoded by `pg_restore`, `pg_dumpall --globals-only`, and the `supabase-db-config` volume, which must hold `pgsodium_root.key`) into `/var/backups/supabase-upgrades/<UTC>`, the folder of the earlier manual backups. `host-audit` compares the host's hashes with `host/<name>` of the `arcane-gitops` checkout after a pull.
|
|
62
62
|
- `arcane manager-upgrade <version>` (`lib/arcane-manager.ts`) follows arcane/AGENTS.md "Manager upgrades": the official image's revision label must equal the release tag's commit (GitHub API), `manager-prepare` records `compose.before.yaml` and every container before the pin commit, the pin goes through the `arcane-gitops` checkout (`git` is exported from `lib/repo.ts` for this), the wait polls `gitops list` and the deployed Compose hash every 30 s for up to 30 minutes, then pull, cold backup, `up -d --no-deps --pull never`, and checks. Any failure before the restart reverts the pin (`stopped`); a failed check after it reverts the pin and runs `manager-rollback` (`rolled back`). The answer always exits 0 with `status`, so the bridge and the agent both see it.
|
|
63
63
|
- `media` runs trendarr unchanged: `trendarrCli` in `media.json` is its `dist/cli.js`, started with `process.execPath` because sudo's PATH has no node. Each call gets `HOME` set to a fresh `0700` directory under `~/.specialists/work/media/` that holds only `.trendarr/config.json` (`0600`, trendarr's own schema, built from the note fields and `media.json`) and is removed in `finally`; trendarr reads no environment variables and has no config flag, and Node's `os.homedir()` follows `$HOME` on POSIX. Every call passes `--json`; `init` is refused. An add prints trendarr's per-ID `results` and exits 0 even when trendarr exits 1 for a failed ID, because the gate shows only stderr on failure; other failures carry trendarr's stderr without its `warning:` lines, which go into the JSON as `warnings`. The bridge's slash commands and Add buttons call the same wrapper through the entry point (`extensions/astro-discord/media.ts`).
|
|
64
64
|
- `arcane release-notes <stack>[/<service>]` is `lib/releases.ts`: a single-image check and `resolveRef` give the running and latest versions, `HttpRegistry.labels` reads `org.opencontainers.image.source` from the latest image (index to linux/amd64 manifest to config blob), and the anonymous GitHub releases API (60 requests an hour, up to 3 pages of 100) gives the releases in between, oldest first. `condenseNotes` keeps each release under 12,000 characters by section priority; `capTotal` drops the oldest releases past 40,000 characters in total.
|
package/specialists/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A specialist is a Pi subagent that is the only way to operate one area of the ho
|
|
|
4
4
|
|
|
5
5
|
| Agent | Area | What it can do |
|
|
6
6
|
|---|---|---|
|
|
7
|
-
| `astro.arcane` | Arcane container platform (VM 100) and its GitOps repository | Every `arcane-cli` operation except its own `config`, `auth`, `self-update`; `update-report` (fresh check of every stack with running and latest release versions); `release-notes <stack>/<service>` (GitHub notes between the two versions); `change-origin <path> <sha256|-> <utc>` (whether a deployment-file change Wazuh saw is a GitOps commit or one of our operations); `project-status`, `deployment check|wait`; `stack-update <stack>` (a stack's pending image updates through GitOps, redeploy, checks, and rollback; across a major version only with `--confirm`, owner approval; held stacks in the repository's `update-holds.json` are refused); `manager-upgrade <version>` and `manager-rollback <stamp>` (the documented manager upgrade, owner approval); `host <command>`: sanitized host checks (memory, stats, logs, OOM, kernel OOM, audit, capacity, storage, Docker usage, service and queue checks)
|
|
7
|
+
| `astro.arcane` | Arcane container platform (VM 100) and its GitOps repository | Every `arcane-cli` operation except its own `config`, `auth`, `self-update`; `update-report` (fresh check of every stack with running and latest release versions); `release-notes <stack>/<service>` (GitHub notes between the two versions); `change-origin <path> <sha256|-> <utc>` (whether a deployment-file change Wazuh saw is a GitOps commit or one of our operations); `project-status`, `deployment check|wait`; `stack-update <stack>` (a stack's pending image updates through GitOps, redeploy, checks, and rollback; across a major version only with `--confirm`, owner approval; held stacks in the repository's `update-holds.json` are refused); `manager-upgrade <version>` and `manager-rollback <stamp>` (the documented manager upgrade, owner approval); `host <command>`: sanitized host checks (memory, stats, logs, OOM, kernel OOM, audit, capacity, storage, Docker usage, service and queue checks) `db-list|db-dump|db-restore` for Mealie and Paperless, and `supabase-backup` (both Supabase databases, roles, and the pgsodium key) through user `spc-arcane` on VM 100; Compose changes of GitOps-managed projects through `git show|write|commit|push`, then `arcane-cli gitops` sync |
|
|
8
8
|
| `astro.identity` | Zitadel; Pomerium, nginx, lego on VM 104; `02-pulsar-proxmox/dmz/` in the homelab repository | Any Zitadel API call (v2, management, admin, auth) with responses redacted; `dmz status|journal|config-template|render|pomerium-restart|nginx-reload|lego-renew|deploy-config`; `git` on the homelab checkout, writes limited to `02-pulsar-proxmox/dmz/` |
|
|
9
9
|
| `astro.network` | UniFi, FreeRADIUS (LXC 108), Tailscale (LXC 105) | Read UniFi sites, devices, clients, networks, zones, firewall policies, WANs; create, update, delete firewall policies; RADIUS and Tailscale checks on Pulsar |
|
|
10
10
|
| `astro.dns` | Technitium primary (Synapse) and secondary (LXC 107); Cloudflare zones `37pla.net`, `monadeo.com` | Read zones and records on both resolvers, resolve, stats; create and delete zones, add, update, delete records on the primary; Cloudflare zones and record add, update, delete |
|
|
@@ -47,6 +47,15 @@ DATABASES = {
|
|
|
47
47
|
"paperless": {"db": "paperless-db", "user": "paperless", "database": "paperless", "app": "paperless", "table": "documents_document"},
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
# The pre-change backup supabase/AGENTS.md asks for, in the layout of the
|
|
51
|
+
# earlier manual ones: both databases, global roles, and db-config, which holds
|
|
52
|
+
# the pgsodium root key that encrypted values need.
|
|
53
|
+
SUPABASE = {"db": "supabase-db", "user": "postgres"}
|
|
54
|
+
SUPABASE_DATABASES = ("postgres", "_supabase")
|
|
55
|
+
SUPABASE_CONFIG = Path("/var/lib/docker/volumes/supabase-db-config/_data")
|
|
56
|
+
SUPABASE_KEY = "./pgsodium_root.key"
|
|
57
|
+
SUPABASE_BACKUPS = Path("/var/backups/supabase-upgrades")
|
|
58
|
+
|
|
50
59
|
# Tracked host files the audit compares with the repository's host/ folder.
|
|
51
60
|
HOST_FILES = (
|
|
52
61
|
("arcane-backup.sh", "/usr/local/bin/arcane-backup.sh"),
|
|
@@ -634,6 +643,79 @@ def op_db_restore(args):
|
|
|
634
643
|
raise Failed("restore failed; see the JSON above")
|
|
635
644
|
|
|
636
645
|
|
|
646
|
+
def to_private_file(argv, target, timeout):
|
|
647
|
+
descriptor = os.open(target, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600)
|
|
648
|
+
with os.fdopen(descriptor, "wb") as out:
|
|
649
|
+
return run(argv, timeout, stdout=out).returncode
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
def archive_readable(path):
|
|
653
|
+
"""pg_restore reads the archive's index, then decodes every entry and row into nothing."""
|
|
654
|
+
for argv in (["pg_restore", "--list"], ["pg_restore", "-f", "/dev/null"]):
|
|
655
|
+
with open(path, "rb") as source:
|
|
656
|
+
if run([DOCKER, "exec", "-i", SUPABASE["db"], *argv], 1800, stdin=source, stdout=subprocess.DEVNULL).returncode != 0:
|
|
657
|
+
return False
|
|
658
|
+
return True
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def op_supabase_backup(args):
|
|
662
|
+
"""Online snapshots of each database (not one snapshot of both), roles, and the key volume; it never deletes a backup."""
|
|
663
|
+
arity(args, 0, 0, "supabase-backup")
|
|
664
|
+
if not container_running(SUPABASE["db"]):
|
|
665
|
+
raise Failed(f"{SUPABASE['db']} is not running")
|
|
666
|
+
if SUPABASE_CONFIG.is_symlink() or not SUPABASE_CONFIG.is_dir():
|
|
667
|
+
raise Failed(f"{SUPABASE_CONFIG} is not a plain directory")
|
|
668
|
+
names = ", ".join(f"'{name}'" for name in SUPABASE_DATABASES)
|
|
669
|
+
database_bytes = int(psql(SUPABASE, f"SELECT sum(pg_database_size(datname)) FROM pg_database WHERE datname IN ({names})", "postgres"))
|
|
670
|
+
root_dir(SUPABASE_BACKUPS)
|
|
671
|
+
free = shutil.disk_usage(SUPABASE_BACKUPS).free
|
|
672
|
+
# Custom-format dumps are compressed, so the databases' size bounds what the dumps need.
|
|
673
|
+
if free < database_bytes:
|
|
674
|
+
raise Failed(f"{free} bytes free under {SUPABASE_BACKUPS}, less than the databases' {database_bytes}; nothing was written")
|
|
675
|
+
stamp = utc_stamp()
|
|
676
|
+
path = SUPABASE_BACKUPS / stamp
|
|
677
|
+
if path.exists():
|
|
678
|
+
raise Failed(f"{path} already exists")
|
|
679
|
+
root_dir(path)
|
|
680
|
+
incomplete = f"{path} is incomplete and has no manifest"
|
|
681
|
+
files = []
|
|
682
|
+
for name in SUPABASE_DATABASES:
|
|
683
|
+
target = path / f"{name}.dump"
|
|
684
|
+
code = to_private_file([DOCKER, "exec", SUPABASE["db"], "pg_dump", "-U", SUPABASE["user"], "-d", name, "-Fc"], target, 3600)
|
|
685
|
+
if code != 0:
|
|
686
|
+
raise Failed(f"pg_dump of {name} failed (exit {code}); {incomplete}")
|
|
687
|
+
with open(target, "rb") as dumped:
|
|
688
|
+
magic = dumped.read(5)
|
|
689
|
+
if magic != b"PGDMP" or not archive_readable(target):
|
|
690
|
+
raise Failed(f"{target.name} did not pass pg_restore's listing and decoding; {incomplete}")
|
|
691
|
+
files.append(target)
|
|
692
|
+
roles = path / "globals.sql"
|
|
693
|
+
code = to_private_file([DOCKER, "exec", SUPABASE["db"], "pg_dumpall", "-U", SUPABASE["user"], "--globals-only"], roles, 600)
|
|
694
|
+
if code != 0 or b"CREATE ROLE" not in roles.read_bytes():
|
|
695
|
+
raise Failed(f"pg_dumpall --globals-only failed (exit {code}) or wrote no role; {incomplete}")
|
|
696
|
+
files.append(roles)
|
|
697
|
+
keys = path / "db-config.tar.gz"
|
|
698
|
+
descriptor = os.open(keys, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600)
|
|
699
|
+
with os.fdopen(descriptor, "wb") as raw, tarfile.open(fileobj=raw, mode="w:gz") as archive:
|
|
700
|
+
archive.add(SUPABASE_CONFIG, arcname=".")
|
|
701
|
+
with tarfile.open(keys, "r:gz") as archive:
|
|
702
|
+
if SUPABASE_KEY not in archive.getnames():
|
|
703
|
+
raise Failed(f"db-config holds no {SUPABASE_KEY[2:]}; {incomplete}")
|
|
704
|
+
files.append(keys)
|
|
705
|
+
sums = {f.name: sha256_file(f) for f in files}
|
|
706
|
+
write_private(path / "SHA256SUMS", "".join(f"{digest} {name}\n" for name, digest in sums.items()).encode())
|
|
707
|
+
image, image_id = must([DOCKER, "inspect", "--format", "{{.Config.Image}} {{.Image}}", SUPABASE["db"]], 30, "docker inspect").split()
|
|
708
|
+
digests = json.loads(must([DOCKER, "image", "inspect", "--format", "{{json .RepoDigests}}", image_id], 30, "docker image inspect"))
|
|
709
|
+
info = {
|
|
710
|
+
"stamp": stamp, "path": str(path), "image": image, "image_id": image_id, "repo_digests": digests,
|
|
711
|
+
"server_version": psql(SUPABASE, "SHOW server_version", "postgres"), "database_bytes": database_bytes,
|
|
712
|
+
"files": {f.name: {"bytes": f.stat().st_size, "sha256": sums[f.name]} for f in files},
|
|
713
|
+
"checked": "dumps listed and fully decoded by pg_restore, roles present, db-config holds the pgsodium key",
|
|
714
|
+
}
|
|
715
|
+
write_private(path / "manifest.json", json.dumps(info, sort_keys=True).encode())
|
|
716
|
+
emit(info)
|
|
717
|
+
|
|
718
|
+
|
|
637
719
|
COMMANDS = {
|
|
638
720
|
"container-memory": op_container_memory,
|
|
639
721
|
"container-stats": op_container_stats,
|
|
@@ -665,6 +747,7 @@ COMMANDS = {
|
|
|
665
747
|
"db-list": op_db_list,
|
|
666
748
|
"db-dump": op_db_dump,
|
|
667
749
|
"db-restore": op_db_restore,
|
|
750
|
+
"supabase-backup": op_supabase_backup,
|
|
668
751
|
}
|
|
669
752
|
|
|
670
753
|
|
|
@@ -27,6 +27,7 @@ describe("Arcane host commands", () => {
|
|
|
27
27
|
);
|
|
28
28
|
expect(buildHostRemote(["db-restore", "mealie", "20261019T120000Z"]).name).toBe("db-restore");
|
|
29
29
|
expect(buildHostRemote(["mealie-api"]).spec.stdinSecret).toBe("MEALIE_API_KEY");
|
|
30
|
+
expect(buildHostRemote(["supabase-backup"]).remote).toBe("supabase-backup");
|
|
30
31
|
const bad = [
|
|
31
32
|
[],
|
|
32
33
|
["rm"],
|
|
@@ -41,6 +42,7 @@ describe("Arcane host commands", () => {
|
|
|
41
42
|
["object-stat", "grimoire", "a/.git/config"],
|
|
42
43
|
["db-dump", "supabase"],
|
|
43
44
|
["db-restore", "mealie", "latest"],
|
|
45
|
+
["supabase-backup", "_supabase"],
|
|
44
46
|
["container-stats", ...Array.from({ length: 9 }, (_, i) => `c${i}`)],
|
|
45
47
|
["manager-start"],
|
|
46
48
|
["manager-rollback", "20261019T120000Z"],
|
|
@@ -46,6 +46,7 @@ export const HOST_COMMANDS: Readonly<Record<string, HostCommand>> = {
|
|
|
46
46
|
"db-list": { args: [1, 1], help: "db-list mealie|paperless this tool's dumps, newest last, with checksums and row counts", timeoutMs: MINUTE },
|
|
47
47
|
"db-dump": { args: [1, 1], help: "db-dump mealie|paperless pg_dump into /var/backups/spc-arcane/<stack>/<UTC> (gzip, checked, sha256)", timeoutMs: 60 * MINUTE },
|
|
48
48
|
"db-restore": { args: [2, 2], help: "db-restore <stack> <stamp> fill an EMPTY database from one of these dumps, the app stopped meanwhile (owner approval)", timeoutMs: 60 * MINUTE },
|
|
49
|
+
"supabase-backup": { args: [0, 0], help: "supabase-backup both Supabase databases, roles, and db-config (pgsodium key) into /var/backups/supabase-upgrades/<UTC>, checked", timeoutMs: 90 * MINUTE },
|
|
49
50
|
"manager-state": { args: [0, 0], help: "manager-state", timeoutMs: MINUTE, internal: true },
|
|
50
51
|
"manager-prepare": { args: [1, 1], help: "manager-prepare <stamp>", timeoutMs: 2 * MINUTE, internal: true },
|
|
51
52
|
"manager-pull": { args: [1, 1], help: "manager-pull <digest>", timeoutMs: 16 * MINUTE, internal: true },
|
|
@@ -92,6 +92,11 @@ describe("stack health after a redeploy", () => {
|
|
|
92
92
|
expect(containersProblem([up("db", { health: "unhealthy" }), up("app", { health: "starting" })], 2)).toBe("health: db (unhealthy), app (starting)");
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
it("ignores the health a finished job inherited from its image", () => {
|
|
96
|
+
expect(containersProblem([up("db"), up("migration", { running: false, state: "exited", exitCode: 0, health: "unhealthy" })], 2)).toBeNull();
|
|
97
|
+
expect(containersProblem([up("db"), up("migration", { running: false, state: "exited", exitCode: 1, health: "unhealthy" })], 2)).toBe("not running: migration");
|
|
98
|
+
});
|
|
99
|
+
|
|
95
100
|
it("names running containers left on an older image than their tag, not finished jobs", () => {
|
|
96
101
|
expect(containersProblem([up("db", { stale: true }), up("redis", { stale: true }), up("app")], 3)).toBe("still on an older image than its tag: db, redis");
|
|
97
102
|
expect(containersProblem([up("init", { running: false, state: "exited", exitCode: 0, stale: true })], 1)).toBeNull();
|
|
@@ -106,7 +106,9 @@ export function isStaleImage(image: unknown): boolean {
|
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
108
|
* Why the stack is not healthy yet, or null when every container runs (or, as
|
|
109
|
-
* a one-shot job, exited with code 0) and
|
|
109
|
+
* a one-shot job, exited with code 0) and no running one is unhealthy or still
|
|
110
|
+
* starting. A finished job keeps the health status of a check inherited from
|
|
111
|
+
* its image (bigcapital's migration reads "unhealthy"), so its health is not read.
|
|
110
112
|
*/
|
|
111
113
|
export function containersProblem(containers: readonly StackContainer[], expected: number): string | null {
|
|
112
114
|
if (containers.length < expected) return `${containers.length} of ${expected} services have a container`;
|
|
@@ -114,7 +116,7 @@ export function containersProblem(containers: readonly StackContainer[], expecte
|
|
|
114
116
|
if (down.length > 0) return `not running: ${down.join(", ")}`;
|
|
115
117
|
const old = containers.filter((c) => c.running === true && c.stale).map((c) => c.name);
|
|
116
118
|
if (old.length > 0) return `still on an older image than its tag: ${old.join(", ")}`;
|
|
117
|
-
const sick = containers.filter((c) => c.health === "unhealthy" || c.health === "starting").map((c) => `${c.name} (${c.health})`);
|
|
119
|
+
const sick = containers.filter((c) => c.running === true && (c.health === "unhealthy" || c.health === "starting")).map((c) => `${c.name} (${c.health})`);
|
|
118
120
|
return sick.length > 0 ? `health: ${sick.join(", ")}` : null;
|
|
119
121
|
}
|
|
120
122
|
|