From e409d38f931dda13527839bc92cc96db481f2fd4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 16 Oct 2026 18:42:59 +0200 Subject: [PATCH] fix(web-app-docs): install the replay engine at replay time, not into the image A host-install block replays a deploy that runs sys-svc-container, which replaces the distribution engine with docker-ce and restarts docker.service. That restart fails with "failed to load listeners: no sockets found via socket activation" when the running docker.socket belongs to the package being replaced. init.sh no longer installs an engine. engine.sh installs and starts one inside the running machine, and machine.sh pipes it in only for a block that nests a `docker run`, which needs a daemon before the deploy inside it installs anything. The replay-image echo now reads the token before `bash -c`, so a mirrored pin prints instead of nothing. Co-Authored-By: Claude Opus 5 (1M context) --- .../tools/github/actions/instructions.md | 4 +- roles/web-app-docs/files/test/engine.sh | 39 +++++++++++++++++++ roles/web-app-docs/files/test/init.sh | 37 +++--------------- roles/web-app-docs/files/test/machine.sh | 13 ++++++- 4 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 roles/web-app-docs/files/test/engine.sh diff --git a/docs/contributing/tools/github/actions/instructions.md b/docs/contributing/tools/github/actions/instructions.md index c4fc0c4bba..7ee43df75d 100644 --- a/docs/contributing/tools/github/actions/instructions.md +++ b/docs/contributing/tools/github/actions/instructions.md @@ -32,7 +32,9 @@ The machine starts from the **distribution base image**, not from an image this Once the machine is up, the repository checkout mounted into it is prepared with [scripts/tests/workspace/base/01_install.sh](../../../../../scripts/tests/workspace/base/01_install.sh), the same step the workspace suite uses: system packages through `INFINITO_PACKAGE_INSTALL_SCRIPT`, then `make install`. Only then is the block replayed, so it meets a machine prepared exactly the way the documentation tells a reader to prepare one. -One service serves both block shapes, because the demands of the two overlap: a host install needs `/sbin/init` as the entrypoint and the cgroup mount to deploy systemd units, and it needs the daemon socket too, since a role without a compose template of its own still pulls in containerised dependencies. A containerised block needs that socket to nest its `docker run` one level below the machine, and a work directory mounted at the same absolute path on both sides so the bind sources it names resolve on the daemon. The union is the machine, and the block decides what it does with it. +One service serves both block shapes: both need `/sbin/init` as the entrypoint and the cgroup mount, and a containerised block additionally needs a work directory mounted at the same absolute path on both sides so the bind sources it names resolve on the daemon. + +The container engine is not part of that image. [engine.sh](../../../../../roles/web-app-docs/files/test/engine.sh) installs and starts one inside the running machine, and [machine.sh](../../../../../roles/web-app-docs/files/test/machine.sh) pipes it in only for a block that nests a `docker run`, which needs a daemon before the deploy inside it installs anything. A host install must not get it: `sys-svc-container` replaces the engine with `docker-ce` and restarts `docker.service`, and that restart fails with `failed to load listeners: no sockets found via socket activation` when the running `docker.socket` belongs to the distribution package being replaced. Such a machine gets its engine from the deploy itself. The block is replayed once systemd reports `running` or `degraded`. A block that opens with `git clone` is a host install: those two lines are dropped and the mounted checkout is used instead, so the replay runs against the tree under test. diff --git a/roles/web-app-docs/files/test/engine.sh b/roles/web-app-docs/files/test/engine.sh new file mode 100644 index 0000000000..fdae1edc97 --- /dev/null +++ b/roles/web-app-docs/files/test/engine.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# shellcheck shell=sh +# +# A block that deploys the machine itself must NOT get this: sys-svc-container +# replaces the engine with docker-ce, and its docker.service restart fails +# when the running docker.socket belongs to the package being replaced. + +set -e + +install_engine() { + if command -v dockerd >/dev/null 2>&1 && command -v docker >/dev/null 2>&1; then + return 0 + fi + + if command -v apt-get >/dev/null 2>&1; then + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends docker.io + command -v docker >/dev/null 2>&1 || + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends docker-cli + rm -rf /var/lib/apt/lists/* + elif command -v dnf >/dev/null 2>&1; then + dnf install -y --allowerasing docker + dnf clean all + elif command -v pacman >/dev/null 2>&1; then + pacman -Sy --noconfirm --needed docker + rm -rf /var/cache/pacman/pkg/* + else + echo "no supported package manager to install a container engine with" >&2 + exit 1 + fi + + if ! command -v docker >/dev/null 2>&1; then + echo "the container engine install left no docker client on PATH" >&2 + exit 1 + fi +} + +install_engine +systemctl enable --now docker.service diff --git a/roles/web-app-docs/files/test/init.sh b/roles/web-app-docs/files/test/init.sh index 465647f844..9b732fd8fb 100644 --- a/roles/web-app-docs/files/test/init.sh +++ b/roles/web-app-docs/files/test/init.sh @@ -1,12 +1,13 @@ #!/bin/sh # shellcheck shell=sh # -# Installs systemd and a container engine into whatever it runs in: the -# Dockerfile beside it RUNs it in a build stage, never run it on a host. +# Installs systemd into whatever it runs in: the Dockerfile beside it RUNs it +# in a build stage, never run it on a host. # -# The engine is not optional. The published instructions end in `docker run`, -# and the machine replaying them carries no host socket, so without a daemon -# of its own every replay dies on `dial unix /var/run/docker.sock`. +# No container engine here: a machine that already carries the distribution's +# engine kills sys-svc-container's docker.service restart with "failed to load +# listeners: no sockets found via socket activation". engine.sh adds one at +# replay time for the blocks that need it before any deploy. set -e @@ -45,31 +46,5 @@ install_init() { [ -e /sbin/init ] || ln -sf /lib/systemd/systemd /sbin/init } -install_engine() { - if ! command -v docker >/dev/null 2>&1 || ! command -v dockerd >/dev/null 2>&1; then - if command -v apt-get >/dev/null 2>&1; then - apt_install docker.io - command -v docker >/dev/null 2>&1 || apt_install docker-cli - elif command -v dnf >/dev/null 2>&1; then - dnf install -y --allowerasing docker - dnf clean all - elif command -v pacman >/dev/null 2>&1; then - pacman -Sy --noconfirm --needed docker - rm -rf /var/cache/pacman/pkg/* - else - echo "no supported package manager to install a container engine with" >&2 - exit 1 - fi - fi - - if ! command -v docker >/dev/null 2>&1; then - echo "the container engine install left no docker client on PATH" >&2 - exit 1 - fi - - systemctl enable docker.service -} - install_init -install_engine mask_units_that_escape_the_container diff --git a/roles/web-app-docs/files/test/machine.sh b/roles/web-app-docs/files/test/machine.sh index 9581111c6a..bb382b45c9 100644 --- a/roles/web-app-docs/files/test/machine.sh +++ b/roles/web-app-docs/files/test/machine.sh @@ -76,6 +76,10 @@ await_engine() { return 1 } +nests_a_container() { + grep -qE '^docker run ' "${BLOCK}" +} + if grep -q '^git clone ' "${BLOCK}"; then echo "=== Dropping the clone; ${DOCS_TEST_SRC_DIR} is the tree under test ===" sed -i -E '/^git clone /d; /^cd core$/d' "${BLOCK}" @@ -93,11 +97,16 @@ trap cleanup EXIT machine up -d --build --pull always echo "=== Machine base digest: $(container image inspect "${MACHINE_BASE_IMAGE}" --format '{{index .RepoDigests 0}}' 2>/dev/null || echo unresolved) ===" await_systemd -await_engine + +if nests_a_container; then + echo "=== Giving it the engine the block's own docker run needs ===" + machine exec -T machine sh -s <"${STAGE}/engine.sh" + await_engine +fi echo "=== Preparing it for Infinito.Nexus (${PREPARE}) ===" in_machine bash "${PREPARE}" -echo "=== Replay image: $(grep -oE '(ghcr|docker)\.io/[^ "]+' "${BLOCK}" | head -1 || true) ===" +echo "=== Replay image: $(sed -nE 's#^[[:space:]]*([^[:space:]]+) bash -c .*#\1#p' "${BLOCK}" | head -1 || true) ===" echo "=== Replaying the instructions in that machine ===" machine exec -T -w "${workdir}" machine bash -e -s <"${BLOCK}"