bug: edge-control add_route targets non-existent Caddy server edge — registration succeeds in registry but traffic never routes #789
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#789
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
tools/edge-control/lib/caddy.shline ~53 POSTs new routes to the Caddy admin API at:The path segment
.../servers/edge/...assumes a Caddy server namededgeexists in the running config. Buttools/edge-control/install.shlines 229-240 emit a Caddyfile with no named server — just a global block and a bare:80, :443 {}site. At runtime Caddy auto-generates server names (conventionallysrv0,srv1, …). There's noedge.Consequence:
allocate_port(lib/ports.sh) writes the project toregistry.jsonsuccessfully →ssh disinto-register@edge "register …"returns a clean JSON with a port and fqdn. The operator's.envgetsEDGE_TUNNEL_PORTset. The edge container's autossh opens the reverse tunnel. But the Caddy admin POST returns 404 or silently writes to a server that doesn't handle HTTPS, and nothing ever reaches the tunnel.The failure is quiet:
curl -X POST /config/apps/http/servers/edge/routeshits an unknown path — Caddy admin API returns error JSON butadd_routeuses2>&1on the curl call and only fails on non-zero exit, not on HTTP 4xx with response body. Soregister.shprintsAdded route: …and the shell exits 0.This would only surface after a real install on a real box, and the current deployment didn't run
edge-controlat all — so the bug is latent but would bite on first use.Fix
Two symmetric options, land both for defense-in-depth:
Part 1 — name the server in the emitted Caddyfile
In
install.sh, the Caddyfile heredoc should declare the server explicitly. Caddyfile syntax doesn't name servers directly, so we go through the JSON config approach (write a JSON config file, not a Caddyfile) OR use the named-matcher + routes machinery. Simplest: convert the emitted config to JSON.Alternative that stays Caddyfile-native: drop the fixed name
edgeinadd_routeand instead discover the server name at runtime. See Part 2.Part 2 —
add_routeshould discover the server name dynamicallyRather than hard-coding
/servers/edge/,lib/caddy.shshould:And symmetrically in
remove_routewhich hardcodes the same path.Part 3 — fail loudly on admin-API errors
Both
add_routeandremove_routecurrently only catch curl's exit code. HTTP 4xx/5xx with an error body reads as success. Check the HTTP status code:Same pattern in
remove_routeandreload_caddy.Affected files
tools/edge-control/install.sh— emit a Caddyfile that produces a server namededge(via config-JSON or a named-block workaround), OR leave the Caddyfile minimal and rely on Part 2tools/edge-control/lib/caddy.sh—add_routeandremove_routeuse dynamic server-name discovery; all three admin-API helpers check HTTP statusAcceptance criteria
ssh disinto-register@edge "register foo ssh-ed25519 AAAAC3..."actually produces a working Caddy route that servesfoo.disinto.ai→127.0.0.1:<port>(end-to-end test: register, open tunnel on the registered port withnc -l <port>, curl the fqdn, see the nc output)Added route:+ success exit)remove_routehandles the same error pathsBlocks
This blocks any real use of edge-control. #788 (landing page preservation) doesn't help if registered projects never actually route.
add_routetargets non-existent Caddy serveredge— registration succeeds in registry but traffic never routes (#789) #790