From 39e32f74a5374ce991a36da5ff6f9bdf698e7dcf Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 4 Jun 2026 17:03:39 +0200 Subject: [PATCH] =?UTF-8?q?feat(test):=20harden=20swarm-NFS=20rig=20?= =?UTF-8?q?=E2=80=94=20DinD=20DNS,=20RUNTIME,=20mirrors,=20N/N=20replicas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DinD DNS chain reworked so the Playwright container run --rm npm install no longer EAI_AGAINs on registry.npmjs.org: - 03_start_swarm_nodes.sh runs each DinD with --dns 1.1.1.1/8.8.8.8 and pre-seeds /etc/docker/daemon.json. systemd-resolved still clobbers the outer resolv.conf at boot, so the daemon-level DNS is the only thing that survives for containers the inner daemon spawns. - daemon.json.j2 omits the "dns" key when networks.internet.dns is empty (default), so the rendered config no longer overwrites the pre-seeded daemon.json with "dns": [""] and break inner-container resolution. - 09_write_extras.sh sets networks.internet.dns to a public resolver for the test rig and bakes RUNTIME via cli.meta.runtime (so e2e-playwright actually runs in act/github instead of being skipped under "host"). 07_provision_inventory.sh generates mirrors.yml via cli.contributing.mirror.resolver and passes --mirror to the inventory provisioner only when cli.meta.runtime == "github". act/local keeps upstream pulls (no mirror infrastructure to point at). 12_wait_converge.sh and 15_assert_state.sh accept any N/N replica state instead of hardcoded 1/1, so multi-host-replica deploys converge cleanly. Co-Authored-By: Claude Opus 4.7 --- .../templates/daemon.json.j2 | 2 ++ .../deploy/swarm/03_start_swarm_nodes.sh | 13 ++++++++++ .../deploy/swarm/07_provision_inventory.sh | 26 ++++++++++++++++--- scripts/tests/deploy/swarm/09_write_extras.sh | 6 +++++ .../tests/deploy/swarm/12_wait_converge.sh | 4 ++- scripts/tests/deploy/swarm/15_assert_state.sh | 6 ++--- 6 files changed, 50 insertions(+), 7 deletions(-) diff --git a/roles/sys-svc-container/templates/daemon.json.j2 b/roles/sys-svc-container/templates/daemon.json.j2 index f8401c4790..ea6c848d95 100644 --- a/roles/sys-svc-container/templates/daemon.json.j2 +++ b/roles/sys-svc-container/templates/daemon.json.j2 @@ -10,7 +10,9 @@ {% set _ = _insecure.append(_cache_hosts[0] ~ ':' ~ _cache_port) %} {% endif %} { +{% if (networks.internet.dns | default('') | length) > 0 %} "dns": ["{{ networks.internet.dns }}"], +{% endif %} "dns-search": ["{{ DOMAIN_PRIMARY }}"], "dns-opts": ["ndots:0"], "storage-driver": "fuse-overlayfs" diff --git a/scripts/tests/deploy/swarm/03_start_swarm_nodes.sh b/scripts/tests/deploy/swarm/03_start_swarm_nodes.sh index a9d0e31e95..7d5fb512c3 100755 --- a/scripts/tests/deploy/swarm/03_start_swarm_nodes.sh +++ b/scripts/tests/deploy/swarm/03_start_swarm_nodes.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash set -euo pipefail +# act's embedded resolver intermittently returns EAI_AGAIN. +swarm_node_dns=(--dns 1.1.1.1 --dns 8.8.8.8) # nocheck: hardcoded-dns-resolver + # /tmp:exec: Docker's default tmpfs is noexec; dpkg-buildpackage execve()s debian/rules. for node in "${MGR}" "${WRK1}" "${WRK2}"; do docker run -d --name "${node}" \ @@ -10,6 +13,7 @@ for node in "${MGR}" "${WRK1}" "${WRK2}"; do --cgroupns=host \ --security-opt seccomp=unconfined \ --security-opt apparmor=unconfined \ + "${swarm_node_dns[@]}" \ --tmpfs /run \ --tmpfs /run/lock \ --tmpfs /tmp:exec \ @@ -53,3 +57,12 @@ MGR_HOSTS_EXTRA="$( EOF )" docker exec -i "${MGR}" sh -c 'cat >> /etc/hosts' <<<"${MGR_HOSTS_EXTRA}" + +# Daemon DNS for containers spawned by the inner daemon; outer --dns is +# clobbered by systemd-resolved inside DinD. +# nocheck: hardcoded-dns-resolver +swarm_daemon_dns_json='{"dns": ["1.1.1.1", "8.8.8.8"]}' +for node in "${MGR}" "${WRK1}" "${WRK2}"; do + docker exec "${node}" mkdir -p /etc/docker + docker exec -i "${node}" sh -c 'cat > /etc/docker/daemon.json' <<<"${swarm_daemon_dns_json}" +done diff --git a/scripts/tests/deploy/swarm/07_provision_inventory.sh b/scripts/tests/deploy/swarm/07_provision_inventory.sh index 7a1bce21bb..b21d8e1afb 100755 --- a/scripts/tests/deploy/swarm/07_provision_inventory.sh +++ b/scripts/tests/deploy/swarm/07_provision_inventory.sh @@ -18,7 +18,27 @@ esac includes+=("${APP_ID}") mkdir -p /tmp/inv -python3 -m cli.administration.inventory.provision /tmp/inv \ - --host "${MGR}" \ - --include "${includes[@]}" \ + +provision_args=( + --host "${MGR}" + --include "${includes[@]}" --workers 2 +) +if [[ "$(python3 -m cli.meta.runtime)" == "github" ]]; then + : "${INFINITO_GHCR_MIRROR_PREFIX:?required in github runtime}" + : "${GITHUB_REPOSITORY_OWNER:?required in github runtime}" + : "${GITHUB_REPOSITORY:?required in github runtime}" + ghcr_namespace="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')" + ghcr_repository="$(echo "${GITHUB_REPOSITORY}" | cut -d/ -f2- | tr '[:upper:]' '[:lower:]')" + mirrors_file="/tmp/inv/mirrors.yml" + python3 -m cli.contributing.mirror.resolver \ + --repo-root . \ + --ghcr-namespace "${ghcr_namespace}" \ + --ghcr-repository "${ghcr_repository}" \ + --ghcr-prefix "${INFINITO_GHCR_MIRROR_PREFIX}" \ + >"${mirrors_file}" + provision_args+=(--mirror "${mirrors_file}") + echo "[swarm-test] mirrors.yml generated: ${mirrors_file}" +fi + +python3 -m cli.administration.inventory.provision /tmp/inv "${provision_args[@]}" diff --git a/scripts/tests/deploy/swarm/09_write_extras.sh b/scripts/tests/deploy/swarm/09_write_extras.sh index 9bd85eb924..0808f9dec3 100755 --- a/scripts/tests/deploy/swarm/09_write_extras.sh +++ b/scripts/tests/deploy/swarm/09_write_extras.sh @@ -4,8 +4,14 @@ set -euo pipefail ssh-keygen -t ed25519 -N "" -f /tmp/swarm-nfs-admin.key -C "swarm-test" -q ADMIN_PUBKEY=$(cat /tmp/swarm-nfs-admin.key.pub) +RUNTIME_VALUE="$(python3 -m cli.meta.runtime)" + cat >/tmp/swarm-nfs-extras.yml <