VersionControl:PRs/maybelle-config/258

From PickiPedia: A knowledge base of bluegrass, old time psychedelic jams, and other public domain music
Revision as of 17:06, 9 November 2026 by DrivingThatTrain (talk | contribs) (cryptograss/maybelle-config#258, as GitHub has it)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
maybelle-config#258: hunter: each Mood's previews by its name, <slug>0-9.hunter, from workbench (Moods as Directories, step 4)
State 🟣 merged 2026-11-01 14:30:38
Worked on by magent, re, justin
Moods #emergence
Deploy hunter, after #256 and #257
Branch mood-previews → production, by magent-cryptograss
Opened · last pushed 2026-11-01 10:28:35 · 2026-11-01 10:28:31
Step 4 of [Cryptograss:Moods as Directories](https://pickipedia.xyz/wiki/Cryptograss:Moods_as_Directories). **Stacked on #257, which is stacked on #256.** Merge in order: #256, #257, then this.

**What it adds**
- **`hunter-mood-previews`** (new `mood-previews` role) runs each minute as root.
  - Every Mood directory under `/opt/magenta/moods` gets **ten preview ports in workbench**, in blocks of ten from 15000. The block is kept in the Mood's `.previews` file, so renaming the directory keeps it. Two directories with a copied `.previews` don't share a block.
  - The file lists each port beside its hostname, so anyone in the Mood can read which ports are theirs.
  - It writes `/etc/caddy/moods.caddy`, with one site for each `<slug><N>.hunter.cryptograss.live` pointing at **workbench's address on magenta-net**. Nothing is published: hunter's host reaches a container's port directly (tested, HTTP 200).
  - It reloads Caddy only when something changed and `caddy validate` accepts the result. If Caddy rejects it, the old config keeps running.
- **Certificates on demand.** Ten hostnames for each Mood, issued all at once, would exceed Let's Encrypt's 50 new certificates a week for cryptograss.live. So `on_demand_tls` asks for a certificate only when a hostname is first visited. It only asks for hostnames listed in `/etc/caddy/moods-ask`, which Caddy itself checks on `localhost:5555`.
- **No clashes.** A Mood named like a container that still has its own `<name>0-9` hostnames (uploads-and-embeds, docs-tests-qa) is left out until that container retires (step 5). Two sites with one address would stop Caddy from loading.
- **The empty `moods.caddy` and `moods-ask`** are created by the caddy role before Caddy first loads the Caddyfile that imports them.

**Tested**
- 8 new tests in `test_mood_previews.py`: blocks given and kept, a rename, a copied `.previews`, reloading only on change, a Mood removed, workbench changing address, a Mood named like a container, no workbench, and only plain slugs. The `hunter` CI job now runs them.
- The rendered Caddyfile, run under **hunter's own Caddy binary (2.6.2)**: `Valid configuration`. The ask endpoint answered **200** for a listed hostname and **404** for an unlisted one, for `../Caddyfile`, and for an empty name.
- `render_diff.py` against production shows the workbench entries, the on-demand block, the ask site and the import, and nothing else.

**Not in this step:** a way for re and blu to start a preview in workbench themselves. For now, people start previews there, and magent through docker.sock. Per-agent keys come when they're needed (discussed in #emergence).

Deploy: hunter, after #256 and #257
Worked on by: magent, re, Justin, in #emergence