Repository navigation
fix(node): serve /metrics during boot and export decdn_node_boot_ready - #2821
Merged
Merged
Conversation
`run` now binds and serves the metrics listener before `build_infra`, so a node that retries its RPC preflight, deployment preflight or boot chain reads still answers scrapes, and `decdn_chain_boot_read_retries_total` is live while those reads retry. The serve task sits in the runtime's `JoinSet`, so a bring-up error stops it and frees the port. `decdn_node_boot_ready` reads 0 from process start and 1 once bring-up finishes, just before the `node runtime ready` banner, so a node stuck in boot can be alerted on directly. ADR appendix-observability gains its registry row and a recommended alert. Closes #2819 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The alert timing documentation needs to distinguish new targets that can alert after about 5 minutes from targets with a previous ready sample, rather than imply a guaranteed 15-minute boot allowance.
1 open issue
What changed in this PR
Makes node startup observable by serving /metrics before boot-time RPC checks, addressing the monitoring gap described in #2819.
Changes:
- Starts the metrics server before infrastructure initialization while preserving shutdown handling.
- Adds
decdn_node_boot_readyto distinguish booting nodes from ready nodes. - Tests both readiness states and updates boot-metrics documentation and alert guidance.
| File | Description |
|---|---|
crates/node/tests/anvil_bringup_shutdown_e2e.rs |
Checks that successful bring-up sets the readiness gauge to 1. |
crates/node/src/runtime/tests.rs |
Checks that metrics respond during boot with readiness 0. |
crates/node/src/runtime/mod.rs |
Starts metrics before boot checks and marks completed bring-up. |
crates/node/src/metrics.rs |
Defines the readiness gauge and its recorder. |
crates/node/src/chain_events/boot_retry.rs |
Updates module comments to describe metrics availability during boot. |
adr/appendix-observability.md |
Documents readiness, alert guidance, and boot retry visibility. |
Review effort: Balanced
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 4 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
… docs `/metrics` serves during boot, so `decdn_rpc_healthy` read its default 0 until the boot chain reads finished, and the RPC alert would page on any slow boot. `build_infra` now seeds it right after the reachability preflight passes. Tests: the listening socket closes after a bring-up error, rpc_healthy reads 1 once the preflight passes, the boot scrape fails fast with run's own error, and the bring-up e2e reads boot_ready over HTTP. Docs: the boot-ready alert window matches the 10-minute boot budget ([15m] window, 10 m `for`), the retry counter lists the deployment preflight, and the stale "metrics binds after boot" claims in comments, the metrics field doc and the runbook describe the current order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 1, 2026
thiras
added a commit
to decdn/devops
that referenced
this pull request
Nov 1, 2026
* feat(monitoring): alert and panel for decdn_node_boot_ready decdn/decdn#2821 serves /metrics during boot, so a node stuck in boot scrapes fine and DecdnNodeDown no longer pages for it. Add DecdnNodeBootStuck (max_over_time(decdn_node_boot_ready[15m]) == 0 for 10m, the appendix-observability recommendation) with promtool tests, and plot min boot ready on the chain dashboard's chain RPC panel. Closes #202 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(monitoring): pin DecdnNodeBootStuck's crash loop and resolve in tests The crash-loop series used bare gaps, which the 5m lookback bridges, so the bare gauge passed it too: model each failed scrape as a staleness marker. Add a node that comes up, to pin the resolve. Name the for, not the boot deadline, as the 10m, and reword the two older "before the first scrape" rationales that #2821 no longer guarantees. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
thiras
added a commit
to decdn/devops
that referenced
this pull request
Nov 1, 2026
* fix: readiness waits for decdn_node_boot_ready, not a 200 decdn/decdn#2821 serves /metrics from process start, with decdn_node_boot_ready 0 until boot finishes, so a 200 no longer means boot is done. One rule everywhere: ready is a 200 with the gauge at 1, or a 200 with no gauge (older releases bind /metrics only after boot). - Role: the readiness probe retries a 200 that says 0, and its advisory warning names which state it ended in. - decdn-compose health: reports boot from the gauge (boot_state). - Chart: the default startupProbe runs `decdn node health` (the admin RPC starts after boot), so the 5-minute budget restarts a stuck boot again and the pod goes Ready only after boot; the render refuses admin_port 0 with that probe and any probe with two handlers. - Molecule: the stub boots with the gauge at 0 then 1 (stuck, legacy and no-metrics modes); slow-readiness covers a stuck boot and, in a side effect, a daemon that never binds; host-env covers a release without the gauge. Closes #204 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix: harden boot-readiness checks after review - Role: a decdn_node_boot_ready sample that is not exactly `1` (0.0, labelled, timestamped) counts as booting, so a format change upstream cannot pass as ready; uri gets timeout: 5, and the warning prints the sample it saw or the last error. The warning is registered. - decdn-compose: boot_state returns (ready, detail), reads labelled and timestamped samples, and no longer claims a gauge a release lacks. - Chart: startupProbe budget 10 min (upstream's boot-read retry budget); the admin_port guard matches `sh -c "decdn node health"` and refuses a string command; NOTES.txt and the README describe the new ordering (the first ContentBlacklist sync is part of boot). - Molecule: the stub's boot clock starts at the first scrape and gains an `error` mode; slow-readiness asserts the warning branch, that a never-binding daemon stayed up, and that a 500 fails the probe on its first attempt; default/host-env assert the probe stopped before its window with no warning. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

What
decdn-nodebound/metricsinspawn_background_tasks, after the RPC preflight, the deployment preflight and the fail-closed boot chain reads. A node stuck in boot exported nothing. On 2026-11-01 the whole fleet showed nodecdn_*samples for about 22 min.runbinds and serves the metrics listener beforebuild_infra. The serve task sits in the runtimeJoinSet, whichrunnow creates and hands tospawn_background_tasks.metrics_stop_txgoes straight fromrunintoShutdownHandles. If bring-up fails, the dropped stop sender ends the accept loop and the listening socket closes. The shutdown order is the same as before: the metrics stop is still the first send.decdn_rpc_healthyis seeded right after the preflight passes. Before, it was seeded after the boot chain reads. With/metricslive during boot, the default0would otherwise page the criticalDecdnRpcUnhealthyalert (== 0for 2 m) on every slow boot.decdn_node_boot_ready. It reads0from process start and1just before thenode runtime readybanner.max_over_time(decdn_node_boot_ready[15m]) == 0for 10 m. On a first boot it fires at 10 m, which matches the boot-read budget.decdn_chain_boot_read_retries_totalrow is corrected, and its list of retried reads now includes the deployment preflight.boot_retry.rsdocs, themetrics.rsfield doc,docs/runbook.mdand the runtime comments.Closes #2819
Reviewer notes
run, the end ofbuild_infra's preflight, and the end ofspawn_background_tasksincrates/node/src/runtime/mod.rsfirst.DecdnNodeDown, because the scrape now succeeds. The decdn/devops companion (decdn/devops#202) adds theDecdnNodeBootStuckrule and a dashboard target, and has to ship with the release that carries this change. On a stuck boot,DecdnNoActiveStreams(15 m) andDecdnDhtRoutingTableEmpty(30 m) now fire too, which is accurate for a node that serves nothing.node_boot_readycovers. It flips after the fail-closed reads and the admin bind. The admin server's start (in its spawned task), the deferred buyer bootstrap and the ALPN router registration come after the flip. The comment at the call site says so.WARNlines, and the docs now say so.metrics::servenever returnsErr, so theexited with errorbranch is unreachable. That predates this PR.Verification
runtime::tests, all new:metrics_listener_serves_during_boot: red onmain, green now.metrics_listener_closes_after_bring_up_error: wiremock sends a delayed fatal400; the test scrapes during the delay, then sees the port refuse connections.rpc_healthy_is_seeded_once_the_preflight_passes: catches the mutant that drops the seed.run's own error.anvil_bringup_shutdown_e2escrapes/metricsover HTTP and assertsdecdn_node_boot_ready 1. It passes, and it fails when thenode_boot_ready()call is removed.cargo nextest run -p decdn-node: 1895 passed.cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo fmt -- --check,CARGO_BUILD_WARNINGS=deny cargo doc -p decdn-node --no-deps --document-private-itemsandmake -C adr check-refsare all clean, and the pre-commit hooks pass. The cargo-denycrypto-bigintadvisory is unrelated and warn-only.adr/:make -C adr check-refs.architecture.mdneeds no change.A metric name: the devops dashboard and alert are tracked in monitoring: alert and panel for decdn_node_boot_ready (decdn#2821) devops#202.
🤖 Generated with Claude Code