Repository navigation
fix(node): aggregate SIGHUP reload errors across sections (#608) - #615
Conversation
Thread a single `ConfigErrorBag` through every reloadable section's resolve so an operator who breaks N fields sees them all in one error, matching the startup-path aggregation from #222 instead of fixing them one SIGHUP at a time. `ConfigErrorBag` and the `*_into` worker variants are re-exported from `decdn_common::config` for the node crate to use. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request refactors the configuration reload logic to aggregate errors across all sections using a shared ConfigErrorBag. Previously, the reload process would terminate at the first encountered error; now, it collects all validation issues and reports them together, matching the behavior of the startup configuration pass. To support this, the ReloadableSection trait and several internal resolution functions were updated to be public and accept the error bag. Additionally, new tests were added to ensure that multiple errors are correctly captured and reported during a reload. I have no feedback to provide as there were no review comments.
Coverage reportTotal: 89.94% (was 89.89%, ▲ +0.04%) — 16676/18542 lines
History
|
There was a problem hiding this comment.
Pull request overview
Improves the node’s SIGHUP hot-reload experience by aggregating config resolution errors across all reloadable sections into a single ConfigErrorBag, matching the startup-path behavior introduced in #222, while preserving the existing all-or-nothing reload semantics.
Changes:
- Thread a single
ConfigErrorBagthrough allReloadableSection::resolvecalls during SIGHUP reload, collapsing it once after all sections run. - Re-export
ConfigErrorBagfromdecdn_common::configand makeresolve_payment_into,resolve_observability_into, andresolve_security_intopublic for cross-section bag sharing. - Add targeted unit tests ensuring (a) aggregation across multiple sections and (b) multiple errors within a single section are both surfaced in one reload error.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/node/src/runtime/reload.rs | Uses a shared ConfigErrorBag across all reloadable sections during SIGHUP reload and adds tests for cross-section and within-section error aggregation. |
| crates/common/src/config/mod.rs | Re-exports ConfigErrorBag and exposes *_into resolver helpers so reload can share a single bag across sections. |
| crates/common/src/config/errors.rs | Makes ConfigErrorBag public (and its API public) so it can be used from the node crate during reload aggregation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address findings from /pr-review-toolkit:review-pr on this branch:
- Demote ConfigErrorBag::{push, check, check_with, has_field} back to
pub(crate); only new/try_with/into_result/problem_count need to be
reachable from the node crate. Restores the IDENTITY_REGION /
IDENTITY_DATA_DIR intra-doc-link on has_field now that it's no longer
pub. The struct's own doc references to `check`/`push` are also
downgraded from intra-doc-links to plain backticks for the same
rustdoc::private_intra_doc_links reason.
- Add ConfigErrorBag::problem_count so the reload-failure warn line
can carry a structured problem_count field for log aggregators
(previously only the bullet list in %err was filterable).
- Drop the hardcoded "payment, observability, cache.pinned_hashes, and
security" section list from the warn message — it would silently
drift when a fifth ReloadableSection is registered. The %err bullet
list still names each offending field; the warn line now just
asserts "all reloadable sections retained at their previous values".
- Reword the module-doc Phase-1 description so the sentinel-buffer
rule matches the broader trait contract ("every section populates
its buffer on every resolve"), not just sections that pushed
problems.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Trim over-explained comments added in the earlier commits on this
branch:
- `ConfigErrorBag::problem_count` doc: drop the `.matches(...).count()`
forensic detail; keep the WHY ("read before `into_result` when the
count is needed alongside the consumed error").
- `runtime::reload` module-doc Phase 1: collapse from 13 lines to 10
while keeping the dyn-safety rationale and sentinel/clear_buffer
invariant, plus the operator-UX framing.
- `reload()` body comment: drop the redundant operator-UX narrative
that the module doc already carries.
- `PinnedHashesSection::resolve` inline: tighten while keeping the
load-bearing safety claim ("`reload()`'s early return guarantees
the placeholder never reaches swap").
- Two new test docstrings: drop the per-test "what's in the config
file" narrative that the test body shows; keep the WHY (all-or-
nothing contract, short-circuit guard).
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
ConfigErrorBagthrough everyReloadableSection::resolveso SIGHUP reload reports every broken field in one error instead of bailing on the first — matches the startup-path aggregation introduced in Add structured config validation pass after resolution that emits all errors at once #222 (closes config: SIGHUP reload should aggregate all resolution problems (like startup #222) #608).ConfigErrorBag(pub) and promoteresolve_payment_into/resolve_observability_into/resolve_security_intotopubso the node crate can share a bag across sections;PinnedHashesSectionusesbag.try_withwith aPinnedHashes::empty()placeholder so later sections still run.problem_countfield for log aggregators; the message no longer hardcodes a section list ("payment, observability, ..."), so it can't drift when a fifthReloadableSectionis added.Public surface
Minimum needed by the node crate:
pub struct ConfigErrorBag+pub fn new/pub fn try_with/pub fn into_result/pub const fn problem_countimpl Default for ConfigErrorBag(required by clippynew_without_defaultsincenewis pub on a pub type)pub fn resolve_payment_into/resolve_observability_into/resolve_security_intoindecdn_common::configInternal helpers (
push,check,check_with,has_field) staypub(crate).Test plan
cargo nextest run -p decdn-node runtime::reload— newreload_aggregates_problems_across_sections(3 fields across 3 sections) andreload_aggregates_two_problems_in_one_section(2 problems within[payment]) pass; existing 22 reload tests (including all-or-nothing rollback + fallible-commit-fails coverage) still pass.cargo nextest run -p decdn-common config— 253 config tests pass.cargo clippy --workspace --all-targets -- -D warningscargo fmt -- --check-D warnings, cargo-deny)🤖 Generated with Claude Code