Repository navigation
fix(edge): load gateway env for caddy validate and reload on retry - #30
Merged
Merged
Conversation
The edge adapter ran `caddy validate` on CT 200 without the Caddy service's EnvironmentFile, so validation failed (empty Cloudflare token) after carrel.Caddyfile and certificates were already pushed. A retry then saw matching files, skipped the reload and reported the domain ready, while Caddy never loaded the new site (TLS alert 80). - Validate through systemd-run with the service EnvironmentFile. - Keep a frontend.unloaded marker until reload succeeds, so a retry reloads even when the files already match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Touch the marker before pushing certificates and re-push while it exists, so a half-pushed bundle or a renewal is reloaded on retry. Apply the same marker to the CT 207 proxy reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
domain_add sysmon.bensonho.winlab.tw(operationf628a636328fa94b07f9363bd631fe38) first failed withbackend_unavailable, then reportedreadyon retry. HTTPS still failed with TLS alert 80 for more than 20 minutes.The edge adapter (
scripts/edge-agent.py) has 2 bugs:caddy validateon CT 200 without the Caddy service'sEnvironmentFile. The Cloudflare token is empty, so validation fails aftercarrel.Caddyfileand the certificates are already pushed.The same failure hit Book on 2026-10-04 (operation
3784e4e2ba0b008b6ead56aa8cfab800).Fix
systemd-run -p EnvironmentFile=/home/user/gateway/.env, the same environment as the service.frontend.unloadedmarker in/var/lib/carrel-edgeuntil the reload succeeds. A retry reloads while the marker exists.Verification
uv run pytest -q: 204 passed; ruff check and format pass.mainand pass with this change.Valid configuration, exit 0.🤖 Generated with Claude Code