fix(tra-898): cloudflared survives power-loss boot race#491
Merged
Conversation
On a cold start after power loss, cloudflared can launch before upstream DNS/internet is reachable. Edge discovery fails, and the default systemd 5-in-10s restart burst is exhausted, parking the unit in 'failed' so it never retries even once the network comes up (observed as Cloudflare 1033). Disable the start-rate limiter (StartLimitIntervalSec=0) and add RestartSec=10 so Restart=always loops patiently until the edge resolves and self-heals. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
🚀 Preview Deployment Update ✅ This PR has been successfully merged into the preview branch. The preview environment will update shortly at: https://app.preview.trakrf.id |
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
After a power loss at the demo box (observed live at Tim's site today as Cloudflare error 1033), the Cloudflare tunnel never came back on its own.
Root cause: on a cold boot,
cloudflaredcan start before upstream DNS/internet is reachable. Edge discovery fails:systemd then restarts it fast enough to exhaust the default 5-in-10s start-rate limit (
Start request repeated too quickly), parking the unit infailed— so it never retries even once the network is up. Every other container recovers fine because onlycloudflaredneeds the external edge.Fix
In the quadlet (
deploy/edge/quadlets/cloudflared.container):[Unit] StartLimitIntervalSec=0— disable the start-rate limiter soRestart=alwaysnever gives up.[Service] RestartSec=10— wait between attempts so retries loop patiently through a slow network-up instead of burning the burst.Verification
Applied live on the demo box:
daemon-reload, confirmedStartLimitIntervalUSec=0/RestartUSec=10son the generated unit, tunnel reconnected (4 QUIC edge connections,app.demo.trakrf.id -> https://traefik:443), 1033 cleared. Manual recovery for an already-failed unit remainssystemctl --user reset-failed cloudflared.service && systemctl --user start cloudflared.service.🤖 Generated with Claude Code