From 862a1429fcdbfd5181bce2df82ef5b32cfd22f93 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 17 Oct 2026 14:49:41 +0200 Subject: [PATCH] fix(web-app-docs): replay the host-install shape the generator also publishes A role without a container stack gets guide mode host, and the README generator renders a git clone plus make install block for it instead of a docker run. The shape guard from 9aa65a7731 refused exactly that block, so every row replaying such a role died on "the block starts no container". That commit claimed the guard was exercised in both directions; what was exercised is that it fires, not that it fires only on something unpublishable. The same commit had dropped the checkout mount the host shape needs. The harness now dispatches on the shape: a docker run block keeps running on the stack host and deploying over ssh into the target, a git clone block is replayed inside the target against the mounted tree, and a block of neither shape still fails because nothing says which machine it addresses. The documentation that still described the two shapes is back in line with the code. Co-Authored-By: Claude Opus 5 (1M context) --- .../tools/github/actions/instructions.md | 6 +- roles/web-app-docs/files/test/README.md | 22 ++++-- roles/web-app-docs/files/test/compose.yml | 1 + roles/web-app-docs/files/test/machine.sh | 77 +++++++++++++------ 4 files changed, 73 insertions(+), 33 deletions(-) diff --git a/docs/contributing/tools/github/actions/instructions.md b/docs/contributing/tools/github/actions/instructions.md index ae15999e3e..0cf91072d6 100644 --- a/docs/contributing/tools/github/actions/instructions.md +++ b/docs/contributing/tools/github/actions/instructions.md @@ -26,13 +26,15 @@ Reading the block off the page rather than out of the tree is the point: a reade Placeholders (``, ``) are filled from the deployment's own values, and `` / `` from an ed25519 pair generated per run under `DOCS_TEST_WORK`. -The block runs on the stack host and deploys into a throwaway target container, which is what the published recipe describes: a managed server reached over SSH. [machine.sh](../../../../../roles/web-app-docs/files/test/machine.sh) brings that target up through [files/test/compose.yml](../../../../../roles/web-app-docs/files/test/compose.yml) under the project `docs-guide-`, and tears it down with `down -v --rmi local`. +A block whose own `docker run` starts the published deploy image runs on the stack host and deploys into a throwaway target container, which is what that recipe describes: a managed server reached over SSH. [machine.sh](../../../../../roles/web-app-docs/files/test/machine.sh) brings that target up through [files/test/compose.yml](../../../../../roles/web-app-docs/files/test/compose.yml) under the project `docs-guide-`, and tears it down with `down -v --rmi local`. + +A role without a container stack publishes the other shape, a host install that configures the machine it runs on. That block is replayed inside the target instead of on the stack host, which is why the target mounts the checkout at the stack host's own path. A block of neither shape fails the test, because nothing tells the harness which of the two machines it addresses. `HOST` is filled with the target's own bridge address, resolved once the container is up. The target joins the default bridge so the recipe's nested `docker run` can reach it; that bridge has no DNS, so the value must be an address rather than a name. The placeholder guard therefore runs after this fill, not before it. The machine starts from the **distribution base image**, not from an image this project publishes, so the replay also exercises the installation. `MACHINE_BASE_IMAGE` is read as `INFINITO_PARENT_IMAGE` out of the `.env` of the mounted checkout, where the env layer has already composed it from the [meta/distros.yml](../../../../../meta/distros.yml) SPOT and honoured any `custom.env` override. A missing `.env` fails the test with a pointer to `make dotenv`. The one build step of [files/test/Dockerfile](../../../../../roles/web-app-docs/files/test/Dockerfile) runs [init.sh](../../../../../roles/web-app-docs/files/test/init.sh), which returns immediately when the base already carries `/sbin/init`. -The target receives nothing but an ssh server before the replay. [sshd.sh](../../../../../roles/web-app-docs/files/test/sshd.sh) installs one, authorizes the run's public key for `root`, and `machine.sh` waits for it to answer. Everything else arrives through the deploy, which is the claim under test. +Before a recipe replay the target receives nothing but an ssh server. [sshd.sh](../../../../../roles/web-app-docs/files/test/sshd.sh) installs one, authorizes the run's public key for `root`, and `machine.sh` waits for it to answer. Everything else arrives through the deploy, which is the claim under test. The target carries no container engine of its own. The replayed deploy installs `docker-ce` and restarts `docker.service`; a target that already ran the distribution's engine fails that restart with `failed to load listeners: no sockets found via socket activation`, because the running `docker.socket` belongs to the package being replaced. Keeping the target bare removes the collision instead of working around it. Its `/var/lib/docker` is a named volume so the installed daemon lands on a real filesystem rather than stacking `fuse-overlayfs` on `fuse-overlayfs`. diff --git a/roles/web-app-docs/files/test/README.md b/roles/web-app-docs/files/test/README.md index 014c2c498f..79a5dbd7c6 100644 --- a/roles/web-app-docs/files/test/README.md +++ b/roles/web-app-docs/files/test/README.md @@ -6,12 +6,14 @@ The CLI test of `web-app-docs` reads the Production block out of the running doc | | What it is | What runs there | | --- | --- | --- | -| ๐Ÿ–ฅ๏ธ **Stack host** | the worker the outer play already runs on | `test.sh`, `machine.sh`, and the published block itself | -| ๐ŸŽฏ **Target** | a throwaway container, project `docs-guide-` | systemd and an ssh server, nothing else until the deploy lands | +| ๐Ÿ–ฅ๏ธ **Stack host** | the worker the outer play already runs on | `test.sh`, `machine.sh`, and a block that starts a container | +| ๐ŸŽฏ **Target** | a throwaway container, project `docs-guide-` | systemd and an ssh server, nothing else until the deploy lands; a host install also runs there | | ๐Ÿณ **Recipe container** | started by the block's own `docker run`, on the stack daemon | the deploy that the instructions tell a reader to run | The target is what the instructions call "a managed server". It is deliberately bare: everything else it ends up with arrives through the deploy under test. +A role that ships no container stack publishes a host install instead of a recipe: a block that opens with `git clone` and configures the machine it runs on. The target is that machine, so the block is replayed inside it over the checkout mounted at `DOCS_TEST_SRC_DIR`, and the two clone lines are dropped so the replay reads the tree under test. A block that neither starts a container nor clones the repository fails the test. + ## Schema ```mermaid @@ -22,6 +24,7 @@ flowchart TD EXTRACT["2๏ธโƒฃ ๐Ÿ“– extract.py
reads the block off the live docs site"] FILL["3๏ธโƒฃ ๐Ÿ”‘ ed25519 pair + placeholder fill
everything except HOST"] MACHINE["4๏ธโƒฃ ๐Ÿšœ machine.sh"] + SHAPE{"๐Ÿ”€ docker run or git clone"} ADDR["7๏ธโƒฃ ๐Ÿ“ HOST = the target's bridge address"] GUARD["8๏ธโƒฃ ๐Ÿšฆ placeholder guard"] BLOCK["9๏ธโƒฃ โ–ถ๏ธ bash -e block.sh"] @@ -31,6 +34,7 @@ flowchart TD direction TB INIT["5๏ธโƒฃ โš™๏ธ systemd, no engine
Dockerfile + init.sh"] SSHD["6๏ธโƒฃ ๐Ÿ” sshd.sh
ssh server + run key for root"] + HOSTRUN["โ–ถ๏ธ bash -e block.sh in the mounted checkout
clone lines dropped"] DEPLOYED["๐Ÿ”Ÿ ๐Ÿ“ฆ docker-ce and the role"] end @@ -38,10 +42,13 @@ flowchart TD TEST --> EXTRACT --> FILL --> MACHINE MACHINE -->|"๐ŸŒ‰ compose up"| INIT - INIT -->|"โณ await systemd"| SSHD + INIT -->|"โณ await systemd"| SHAPE + SHAPE -->|"๐Ÿณ recipe"| SSHD + SHAPE -->|"๐Ÿ  host install"| HOSTRUN SSHD --> ADDR --> GUARD --> BLOCK BLOCK --> RECIPE RECIPE -->|"๐Ÿ”— ssh as root"| DEPLOYED + HOSTRUN --> DEPLOYED MACHINE -.->|"๐Ÿงน trap EXIT"| TARGET classDef host fill:#e8f0fe,stroke:#1a73e8,color:#102a43; @@ -49,12 +56,12 @@ flowchart TD classDef pivot fill:#fef7e0,stroke:#b06000,color:#3d2600; classDef recipe fill:#f3e8fd,stroke:#8430ce,color:#2a0b45; class TEST,EXTRACT,FILL,MACHINE,BLOCK host; - class INIT,SSHD,DEPLOYED target; - class ADDR,GUARD pivot; + class INIT,SSHD,HOSTRUN,DEPLOYED target; + class SHAPE,ADDR,GUARD pivot; class RECIPE recipe; ``` -๐Ÿ”ต stack host ยท ๐ŸŸข target ยท ๐ŸŸฃ the recipe's own container ยท ๐ŸŸ  the two steps that bridge them +๐Ÿ”ต stack host ยท ๐ŸŸข target ยท ๐ŸŸฃ the recipe's own container ยท ๐ŸŸ  the steps that bridge them ## Flow @@ -65,6 +72,7 @@ flowchart TD | 3๏ธโƒฃ | ๐Ÿ”‘ key pair and placeholders | an ed25519 pair per run under `DOCS_TEST_WORK`; every placeholder except `HOST` is substituted | | 4๏ธโƒฃ | ๐Ÿšœ `machine.sh` brings the target up | from `compose.yml`, on the default bridge | | 5๏ธโƒฃ | โš™๏ธ the target boots | image built from `Dockerfile` + `init.sh`; `MACHINE_BASE_IMAGE` comes from `INFINITO_PARENT_IMAGE` in the checkout's `.env` | +| ๐Ÿ”€ | the shape decides where the block runs | `docker run` on the stack host, `git clone` inside the target; steps 6๏ธโƒฃ to 9๏ธโƒฃ are the first of the two | | 6๏ธโƒฃ | ๐Ÿ” `sshd.sh` is piped in | installs an ssh server, authorizes the run's public key for `root`, writes a `PermitRootLogin prohibit-password` drop-in | | 7๏ธโƒฃ | ๐Ÿ“ `HOST` is filled | `container inspect --type container` reads the bridge address; the bridge has no DNS, so it is an address and not a name | | 8๏ธโƒฃ | ๐Ÿšฆ the guard runs | fails on any remaining `` | | `DOCS_TEST_DNS` | `templates/test.env.j2` | fills `` | -| `DOCS_TEST_SRC_DIR` | `templates/test.env.j2` | checkout holding the generated `.env` | +| `DOCS_TEST_SRC_DIR` | `templates/test.env.j2` | checkout holding the generated `.env`; mounted into the target at the same path, where a host install replays from it | | `DOCS_TEST_TIMEOUT` | `templates/test.env.j2` | wait for the on-demand documentation build | | `DOCS_TEST_WORK` | `test.sh` | holds the replay key pair | | `DOCS_TEST_REPLAY_PUBKEY` | `test.sh` | public half, consumed by `sshd.sh` | diff --git a/roles/web-app-docs/files/test/compose.yml b/roles/web-app-docs/files/test/compose.yml index 95d2d31aad..fb71c7eff4 100644 --- a/roles/web-app-docs/files/test/compose.yml +++ b/roles/web-app-docs/files/test/compose.yml @@ -13,6 +13,7 @@ services: - /run - /run/lock volumes: + - ${DOCS_TEST_SRC_DIR}:${DOCS_TEST_SRC_DIR} - /sys/fs/cgroup:/sys/fs/cgroup:rw - engine:/var/lib/docker diff --git a/roles/web-app-docs/files/test/machine.sh b/roles/web-app-docs/files/test/machine.sh index 9019509e6b..c5c09ee7bc 100644 --- a/roles/web-app-docs/files/test/machine.sh +++ b/roles/web-app-docs/files/test/machine.sh @@ -6,7 +6,8 @@ # # Env (test.env): # DOCS_TEST_ROLE role under replay, names the compose project -# DOCS_TEST_SRC_DIR repository checkout, holds the generated .env +# DOCS_TEST_SRC_DIR repository checkout, holds the generated .env and +# carries the tree a host install replays from # DOCS_TEST_WORK work directory, holds the replay key pair # DOCS_TEST_REPLAY_PUBKEY public half, authorized for root on the target @@ -86,6 +87,50 @@ await_ssh() { return 1 } +guard_placeholders() { + if grep -q '&2 + grep -o '' "${BLOCK}" | sort -u >&2 + return 1 + fi + return 0 +} + +replay_over_ssh() { + echo "=== Giving the target an ssh server the published recipe can reach ===" + machine exec -T -e DOCS_TEST_REPLAY_PUBKEY machine sh -s <"${STAGE}/sshd.sh" + + local address + address="$(target_address)" + if [ -z "${address}" ]; then + echo "the ${DOCS_TEST_ROLE} target reported no bridge address" >&2 + return 1 + fi + await_ssh "${address}" + + sed -i "s#^HOST=.*#HOST=${address}#" "${BLOCK}" + guard_placeholders + + echo "=== Replay image: $(sed -nE 's#^[[:space:]]*([^[:space:]]+) bash -c .*#\1#p' "${BLOCK}" | head -1 || true) ===" + echo "=== Replaying the instructions against ${address} ===" + (cd "${DOCS_TEST_WORK}" && bash -e "${BLOCK}") +} + +replay_in_target() { + guard_placeholders + + if ! machine exec -T machine test -f "${DOCS_TEST_SRC_DIR}/Makefile"; then + echo "the target carries no checkout at ${DOCS_TEST_SRC_DIR}, so the host install has no tree to replay from" >&2 + return 1 + fi + + echo "=== Dropping the clone; ${DOCS_TEST_SRC_DIR} is the tree under test ===" + sed -i -E '/^git clone /d; /^cd core$/d' "${BLOCK}" + + echo "=== Replaying the instructions inside the target ===" + machine exec -T -w "${DOCS_TEST_SRC_DIR}" machine bash -e -s <"${BLOCK}" +} + REPLAY_KEY="${DOCS_TEST_WORK}/docs-guide-${DOCS_TEST_ROLE}-key" RECIPE_WORKDIR="${HOME}/.infinito.nexus" if [ -e "${RECIPE_WORKDIR}" ]; then @@ -94,8 +139,12 @@ else RECIPE_WORKDIR_PREEXISTED=0 fi -if ! grep -qE '^docker run ' "${BLOCK}"; then - echo "the ${DOCS_TEST_ROLE} block starts no container; this harness replays it on the stack host and would configure the host itself" >&2 +if grep -qE '^docker run ' "${BLOCK}"; then + REPLAY=replay_over_ssh +elif grep -qE '^git clone ' "${BLOCK}"; then + REPLAY=replay_in_target +else + echo "the ${DOCS_TEST_ROLE} block neither starts a container nor clones the repository, so this harness cannot tell whether it addresses a server or the machine it runs on" >&2 exit 1 fi @@ -108,24 +157,4 @@ trap cleanup EXIT machine up -d --build --pull always await_systemd -echo "=== Giving the target an ssh server the published recipe can reach ===" -machine exec -T -e DOCS_TEST_REPLAY_PUBKEY machine sh -s <"${STAGE}/sshd.sh" - -TARGET_ADDRESS="$(target_address)" -if [ -z "${TARGET_ADDRESS}" ]; then - echo "the ${DOCS_TEST_ROLE} target reported no bridge address" >&2 - exit 1 -fi -await_ssh "${TARGET_ADDRESS}" - -sed -i "s#^HOST=.*#HOST=${TARGET_ADDRESS}#" "${BLOCK}" - -if grep -q '&2 - grep -o '' "${BLOCK}" | sort -u >&2 - exit 1 -fi - -echo "=== Replay image: $(sed -nE 's#^[[:space:]]*([^[:space:]]+) bash -c .*#\1#p' "${BLOCK}" | head -1 || true) ===" -echo "=== Replaying the instructions against ${TARGET_ADDRESS} ===" -(cd "${DOCS_TEST_WORK}" && bash -e "${BLOCK}") +"${REPLAY}"