Skip to content

Commit 7468557

Browse files
committed
Expose API-origin playback through Caddy
1 parent 857c82c commit 7468557

7 files changed

Lines changed: 29 additions & 7 deletions

docs/deployment-automation.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ The GitHub Actions workflow is `.github/workflows/release-deploy.yml`.
1919
Before preflight, the deploy wrapper installs the current
2020
`control-plane.compose.yml`, patches an existing concrete Caddyfile to use
2121
the managed upstream snippet, creates that snippet if it is missing, and
22-
leaves any existing upstream target intact. The bootstrap also removes
22+
leaves any existing upstream target intact. It also repairs public Caddy
23+
matchers so `/v/*` reaches the control-plane API for Tigris-backed playback.
24+
The bootstrap also removes
2325
legacy `admin off` Caddy settings and reloads Caddy while the upstream still
2426
points at the current slot; if that one-time reload fails, it restarts Caddy
2527
before the deploy transaction begins so later promotions can use normal

docs/deployment-v1.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ The SSH wrapper also bootstraps production host files before preflight: it
407407
installs the current control-plane Compose template, patches an existing
408408
concrete Caddyfile to use the managed upstream snippet, creates
409409
`/etc/caddy/rend-control-plane-upstream.caddy` only when missing, removes
410-
legacy `admin off` Caddy settings, and preserves an existing upstream target.
410+
legacy `admin off` Caddy settings, ensures public `/v/*` playback reaches the
411+
control-plane API, and preserves an existing upstream target.
411412
The bootstrap reloads Caddy while the upstream still points at the current slot;
412413
if an older running config cannot reload because admin was disabled, it performs
413414
one restart before the transaction starts so later blue/green promotions can use

docs/edge-host-runbook-v1.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ own public TLS. Checked Caddy templates live in:
160160
- `docs/templates/control-plane-upstream.Caddyfile`
161161
- `docs/templates/edge-host.Caddyfile`
162162

163-
The control-plane template exposes `api.rend.so` for the public `/v1/*` API and
164-
`/readyz`, blocks `/internal/*` on that public hostname, and allows only
165-
configured edge source IPs to `/internal/*` on `api-internal.play.rend.so`.
163+
The control-plane template exposes `api.rend.so` for the public `/v1/*` API,
164+
API-origin playback under `/v/*`, and `/readyz`, blocks `/internal/*` on that
165+
public hostname, and allows only configured edge source IPs to `/internal/*` on
166+
`api-internal.play.rend.so`.
166167
The edge template has a public hostname that blocks `/internal/*` and
167168
`/metrics`, proxies only canonical lowercase UUID playback paths, and returns
168169
`404` for `/v/probe`, non-UUID `/v/*`, and every other path. It also has a

docs/templates/control-plane.Caddyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import /etc/caddy/rend-control-plane-upstream.caddy
1818
}
1919

2020
@public_api {
21-
path /v1/* /readyz
21+
path /v1/* /v/* /readyz
2222
}
2323
handle @public_api {
2424
import rend_active_control_plane

scripts/bootstrap-control-plane-host-files.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,17 @@ for index, line in enumerate(lines):
165165
lines[index] = f"{match.group(1)}import rend_active_control_plane"
166166
replaced = True
167167
168+
public_path_pattern = re.compile(r"^(\s*)path\s+(.+)$")
169+
for index, line in enumerate(lines):
170+
match = public_path_pattern.match(line)
171+
if not match:
172+
continue
173+
paths = match.group(2).split()
174+
if "/v1/*" in paths and "/readyz" in paths and "/v/*" not in paths:
175+
insert_at = paths.index("/v1/*") + 1
176+
paths.insert(insert_at, "/v/*")
177+
lines[index] = f"{match.group(1)}path {' '.join(paths)}"
178+
168179
has_snippet_import = any(line.strip() == "import rend_active_control_plane" for line in lines)
169180
if not has_snippet_import:
170181
if not replaced and source_text == template.read_text(encoding="utf-8"):

scripts/test-control-plane-blue-green-deploy.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ cat >"$bootstrap_case/backups/old/Caddyfile" <<'EOF'
198198
}
199199
200200
api.example.test {
201+
@public_api {
202+
path /v1/* /readyz
203+
}
201204
handle {
202205
reverse_proxy 127.0.0.1:4000
203206
}
@@ -217,6 +220,10 @@ if ! grep -q 'import rend_active_control_plane' "$bootstrap_case/etc/caddy/Caddy
217220
echo "bootstrap-host-files: expected patched Caddyfile to use managed upstream import" >&2
218221
exit 1
219222
fi
223+
if ! grep -q 'path /v1/\* /v/\* /readyz' "$bootstrap_case/etc/caddy/Caddyfile"; then
224+
echo "bootstrap-host-files: expected public Caddy matcher to include API-origin /v/* playback" >&2
225+
exit 1
226+
fi
220227
if ! grep -q 'rend-control-plane-upstream.caddy' "$bootstrap_case/etc/caddy/Caddyfile"; then
221228
echo "bootstrap-host-files: expected patched Caddyfile to import managed upstream snippet" >&2
222229
exit 1

scripts/validate-edge-deploy-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ require_contains docs/templates/control-plane.Caddyfile 'remote_ip {$REND_CONTRO
251251
require_contains docs/templates/control-plane.Caddyfile 'REND_PUBLIC_API_HOSTNAME'
252252
require_contains docs/templates/control-plane.Caddyfile 'import /etc/caddy/rend-control-plane-upstream.caddy'
253253
require_contains docs/templates/control-plane.Caddyfile 'import rend_active_control_plane'
254-
require_contains docs/templates/control-plane.Caddyfile "path /v1/* /readyz"
254+
require_contains docs/templates/control-plane.Caddyfile "path /v1/* /v/* /readyz"
255255
require_contains docs/templates/control-plane.Caddyfile "path /internal/*"
256256
require_contains docs/templates/control-plane.Caddyfile "respond 404"
257257
require_not_contains docs/templates/control-plane.Caddyfile "admin off"

0 commit comments

Comments
 (0)