feat(test): harden swarm-NFS rig — DinD DNS, RUNTIME, mirrors, N/N replicas

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 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Opus 4.7 committed 2026-06-04 17:11:07 +02:00
1 parent 411bcfe4fe
commit 39e32f74a5
6 files changed
+50 -7

No files matched your search

@@ -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"
@@ -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
@@ -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[@]}"
@@ -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 <<EOF
RUNTIME: "${RUNTIME_VALUE}"
TLS_MODE: "self_signed"
networks:
internet:
dns: "1.1.1.1" # nocheck: hardcoded-dns-resolver
storage:
backend: nfs
nfs:
@@ -35,7 +35,9 @@ for i in $(seq 1 90); do
echo "[${i}] ${ENTITY}: ${app_replicas} | state: ${app_state} | db(${DB_DEP}): ${db_state}"
app_ok="false"
if [ "${app_replicas}" = "1/1" ] && echo "${app_state}" | grep -q '^Running'; then
if [ -n "${app_replicas}" ] &&
echo "${app_replicas}" | grep -qE '^([0-9]+)/\1$' &&
echo "${app_state}" | grep -q '^Running'; then
app_ok="true"
fi
db_ok="true"
@@ -10,13 +10,13 @@ for i in $(seq 1 60); do
REPL=$(docker exec "${MGR}" docker service ls \
--filter "name=${SERVICE_NAME}" --format '{{.Replicas}}')
echo "[${i}] ${ENTITY} replicas: ${REPL}"
if [ "${REPL}" = "1/1" ]; then
if echo "${REPL}" | grep -qE '^([0-9]+)/\1$'; then
break
fi
sleep 2
done
[ "${REPL}" = "1/1" ] || {
echo "Replicas != 1/1: ${REPL}"
echo "${REPL}" | grep -qE '^([0-9]+)/\1$' || {
echo "Replicas not fully converged: ${REPL}"
exit 1
}