From 446ea2ac453b7897232f20f27b3bbbb682a8f446 Mon Sep 17 00:00:00 2001 From: Ilia Denisov Date: Fri, 3 Jul 2026 23:04:19 +0200 Subject: [PATCH] fix(ci): arm the maintenance flag on the test-contour deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The maintenance overlay never showed on the test contour: only prod-deploy.sh raised the caddy maintenance flag, so a test redeploy was a bare gateway/backend recreate — the SPA saw a transient 502 ("Reconnecting…"), never the 503 + X-Scrabble-Maintenance marker the overlay keys on. So the feature (PR #171) was unverifiable off prod. Raise the flag around the recreate in ci.yaml's deploy job too, mirroring prod. Ordering matters because of the config reseed: ci does `rm -rf $conf` + recreate, so the running caddy sits on the stale pre-reseed bind mount and cannot see a flag written to the new dir until it is recreated. So: raise the flag, force-recreate caddy FIRST (onto the fresh mount, where it carries the flag and 503s), then recreate gateway/backend (the window), then the other config services, then lower it. A trap clears the flag if the step fails, and the next deploy's reseed wipes a stale one — so the contour can't stick in maintenance. The caddy-routed probes run in the next step, after the flag is lowered. Prod was already correct (prod-deploy.sh); this only makes the test contour faithful so the overlay + reload can be seen there. An open SPA must already be on the PR-#171 bundle (which carries the overlay code) — reload once to bootstrap onto it. --- .gitea/workflows/ci.yaml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 99880c1..e81e94e 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -399,6 +399,13 @@ jobs: mkdir -p "$conf" cp -r caddy otelcol prometheus tempo grafana blackbox "$conf"/ export SCRABBLE_CONFIG_DIR="$conf" + # Maintenance page for the redeploy window, mirroring prod-deploy.sh so the SPA + # overlay is exercised on the test contour too (not only prod). Raised just before + # the recreate and lowered once caddy is back (below); the trap clears it if the + # step fails so the contour never sticks in maintenance (and the reseed above wipes a + # stale flag anyway). The caddy-routed probes run in the NEXT step, after it is lowered. + maint_flag="$conf/caddy/on" + trap 'rm -f "$maint_flag"' EXIT # Derive the public URLs from the one canonical origin instead of storing each as # its own variable (paths are structural SPA routes / the Caddy /_gm sub-path). # Exported before build so the VK ID redirect is baked into the SPA. @@ -430,12 +437,23 @@ jobs: # bot on its own host instead (deploy/docker-compose.bot.yml), and the prod # main host omits both. Without the profile they would not start here. docker compose --ansi never --profile telegram-local build --progress plain + # Raise the maintenance page, THEN bring caddy onto the reseeded config mount so it + # actually carries the flag: the running caddy sits on the stale pre-reseed mount (the + # dir was rm'd + recreated — see the force-recreate note below), so a flag written to + # the new dir is invisible until caddy is recreated. With the fresh caddy up, an open + # SPA sees the 503 marker + overlay for the whole recreate window, not a bare reconnect. + : > "$maint_flag" + docker compose --ansi never up -d --force-recreate --no-deps caddy docker compose --ansi never --profile telegram-local up -d --remove-orphans # The config-only services bind-mount the reseeded config dir. A plain `up -d` # leaves them on the previous bind mount (the dir was rm'd + recreated), so a - # changed Caddyfile or Grafana dashboard is ignored — force-recreate them to - # pick up the fresh config. - docker compose --ansi never up -d --force-recreate --no-deps caddy otelcol prometheus tempo grafana + # changed Grafana dashboard is ignored — force-recreate them to pick up the fresh + # config. (Caddy was already recreated above so it would carry the maintenance flag.) + docker compose --ansi never up -d --force-recreate --no-deps otelcol prometheus tempo grafana + # Lower the maintenance page: services are back. An open SPA's poll now gets through + # (once the gateway finishes booting) and reloads into the fresh client; the caddy + # probes in the next step see 200. The EXIT trap is a backstop if we failed earlier. + rm -f "$maint_flag" - name: Probe the landing, gateway and backend run: | -- 2.52.0