Repository navigation
fix(pm-stack): harden pm-dispatch/pm-tunnel startup + tunnel watchdog, add outside dispatch probe (#6992) - #8391
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37d1fbe2d8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| gh issue create \ | ||
| --title "dispatch probe: dispatch.security.cab public path DOWN" \ | ||
| --label meta/dispatch-probe \ | ||
| --body "$body" |
There was a problem hiding this comment.
Enqueue new probe alerts or document their queue exemption
When an outage occurs without an existing open alert, this branch files an issue but neither enqueues its triage packet nor explains why it is deliberately excluded from the queue. A persistent public-path outage therefore produces no worker task to investigate it; the standing queue reconciliation defaults to observe-only rather than guaranteeing repair. Enqueue the alert in the same pass, or record the deliberate exemption in its filing text, as required by the filing rule in AGENTS.md.
AGENTS.md reference: AGENTS.md:L62-L66
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dba5e00 (shepherd commit by lane code-y, task 11451): the alert body the workflow files now records the deliberate exemption in the filing text itself, per the AGENTS.md filing rule — a GitHub Actions workflow has no path to the fleet queue backend, so the alert is not enqueued at filing time; the standing coverage reconciliation (scripts/fleet/queue-reconcile/) enqueues every open issue into repo-health-code-pilot, and the alert issue is the tracked item until it closes. Enqueueing from the workflow is not possible (the queue broker lives on the fleet laptop/Turso backend, unreachable from GitHub Actions), so the documented-exemption branch of the rule is the applicable one.
| OnBootSec = "2min"; | ||
| OnUnitActiveSec = "2min"; | ||
| Unit = "pm-tunnel-watchdog.service"; |
There was a problem hiding this comment.
Register the new tunnel-watchdog timer
Enabling pm-stack now installs a recurring laptop systemd timer, but this change does not register it in doc/fleet-schedule-registry.md. Searching the registry for the timer name and tunnel aliases found no corresponding entry, so the new recurring work is invisible to the fleet placement inventory. Add its cadence and service pointer in the same change, as required by the Fleet schedules rule in AGENTS.md.
AGENTS.md reference: AGENTS.md:L53-L58
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dba5e00: pm-tunnel-watchdog.timer is now registered in doc/fleet-schedule-registry.md Surface 2b (cadence OnUnitActiveSec=2min,OnBootSec=2min, activates pm-tunnel-watchdog.service, marked Nix-configured / not yet loaded, header counts updated). Same defect class in the same PR also fixed: the new dispatch-health-probe GitHub Actions workflow is registered in Surface 4.
| # hostname resolves. On timeout start anyway (cloudflared keeps | ||
| # retrying internally; the watchdog below covers the rest). | ||
| for i in $(seq 1 90); do | ||
| if ${pkgs.glibc}/bin/getent hosts region1.v2.argotunnel.com >/dev/null 2>&1; then |
There was a problem hiding this comment.
Reference the getent output in the DNS readiness check
Every pm-tunnel start now waits the full 180 seconds even when DNS is healthy: ${pkgs.glibc} resolves to the library output, but the pinned glibc derivation moves bin/getent into a separate getent output, so this command always fails with its error suppressed. Besides never checking resolver readiness, this adds three minutes of downtime to every watchdog-triggered restart. Reference ${pkgs.glibc.getent}/bin/getent instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dba5e00: waitForDns now calls ${pkgs.glibc.getent}/bin/getent. Verified against the pinned nixpkgs on the laptop: glibc has a getent output ((import <nixpkgs> {}).glibc.getent.name → "glibc-2.44-57"), and the module still parses (nix-instantiate --parse clean). The readiness check now actually probes DNS instead of always burning the 180s timeout.
…, add outside dispatch probe (#6992)
…chedule registry, probe queue note (#6992) P2: waitForDns used ${pkgs.glibc}/bin/getent, which never exists (getent is a separate glibc output) — every pm-tunnel start burned the full 180s wait. Use ${pkgs.glibc.getent}/bin/getent (verified: glibc has a getent output in the pinned nixpkgs). P1: register pm-tunnel-watchdog.timer in doc/fleet-schedule-registry.md Surface 2b, and the dispatch-health-probe workflow in Surface 4 (same defect class, same rule). P1: the probe alert issue now records why it is deliberately not enqueued at filing time (AGENTS.md filing rule): a GitHub Actions workflow has no path to the fleet queue backend; the standing coverage reconciliation enqueues every open issue.
37d1fbe to
dba5e00
Compare
Issue #6992 / task 11451 (lane code-j): harden pm-dispatch/pm-tunnel startup against network-not-ready, restart the tunnel when its edge connections stay down, and add the outside health probe.
Root cause (triage task 11437, re-verified live 2026-11-11): the dispatch app never emits 502 — the Cloudflare edge answers 502 while the tunnel has no live connector. The connector can be process-alive with zero live edge connections, so
Restart=on-failurenever fires and the outage is only noticed by the next scheduled consumer, a day later.Changes (nixos/services/pm-stack/default.nix)
ExecStartPrewaits (up to 180s, then starts anyway) fortailscale0to carry an IPv4 address before the server bindsDISPATCH_HOSTS— no more EADDRNOTAVAIL crash-loop at boot; ordered aftertailscaled.serviceas well;TimeoutStartSec=300to hold the wait.ExecStartPrewaits until the Cloudflare edge hostname resolves (local stub-resolver readiness at boot); cloudflared now runs with--metrics 127.0.0.1:20242so its/readyendpoint is available locally./ready; three consecutive failures restartpm-tunnel. Any success resets the counter.pm-stack/systemd/are historical (kept per the module header) and unchanged.Outside probe (.github/workflows/dispatch-health-probe.yml)
Every 30 minutes from GitHub's network:
GET https://dispatch.security.cab/healthmust be 200 and an unauthenticatedPOST /v1/sessionsmust get the app's own 401 (an edge 502/000 fails), 3 attempts over ~2 minutes. Failure opens or updates onemeta/dispatch-probealert issue; the next green run comments the recovery and closes it. Detection target: under an hour, per the packet.Verification
pm-dispatchrestarts clean, and/readyanswers on the metrics port. Results recorded on issue pm-dispatch: POST /v1/sessions and /v1/tasks answer HTTP 502 — daily upstream sync dead since 2026-11-04 #6992.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.