Repository navigation
fix(common,node,cli): route config-resolve notices to the log stream (#1902) - #1915
Conversation
…1902) Every `*_into` resolver wrote its non-fatal warnings with `eprintln!`, on the documented grounds that no `tracing` subscriber exists at `resolve_config` time. That holds for startup, but `resolve_security_into` also runs on the SIGHUP reload path, against a daemon whose subscriber has been live for hours. An operator on `log_format = "json"` who set `security.max_tracked_sources = 0` and reloaded got the "bookkeeping map is unbounded" warning on a stderr nobody was reading, and nothing in their log pipeline — the reload's own "section applied" event carried the new value but neither the severity nor the word to alert on. The resolvers now record `ConfigNotice`s on the shared bag, which is already threaded through every `*_into` worker at startup and through every reloadable section on SIGHUP, so the reload path is covered with no change to `ReloadableSection::resolve`. The caller renders them once it knows which sink it has: `decdn-node` replays them right after `init_tracing`, `RuntimeReloadState::reload` emits them on the success path only, `decdn config validate` prints them under its field summary, and `decdn node doctor` turns them into findings — the last of which matters because `crates/cli` links no subscriber at all. Nothing became a hard error. `0 = unbounded` stays a documented escape hatch, and an inherited orchestrator env var must not refuse boot. - All ten former `eprintln!` sites convert: the retired-env-var notice, the well-known-port notice, the #843 `--relay-url`-overrides-the-list notice, and the unbounded-map notices across `security`, `dht.rate_limit` and `probe.rate_limit`. Each is now asserted; previously the only thing a test could check was that the value resolved, which `mod.rs` said in as many words ("other untested `eprintln!` resolve warnings"). - `ConfigErrorBag` becomes `ConfigDiagnostics`: it carries both channels now, and `bag.warn(…)` on a type named `…ErrorBag` reads wrong. - Notices carry a severity. An unbounded bookkeeping map or a collapsed relay-failover list is `Warn` and moves `doctor`'s exit status; a deliberately disabled rate limit is `Info` and does not. - `warn_retired_env_vars` moves below the bag it now writes to, and its discarded `_retired` return — the half-built version of this mechanism — collapses into the one call. - The SIGHUP regression guard reuses the `sighup_signal.rs` capture harness (thread-local `set_default`, `current_thread` runtime, reload awaited inline) and also pins the negative: an aborted reload emits no notices, because it applies nothing. Closes #1902 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GqvbhAgEkq1XQ9Dm8TvLsq
There was a problem hiding this comment.
🟢 Approval recommended
The change cleanly routes resolve-time diagnostics to appropriate sinks across startup/reload/CLI paths and is backed by targeted unit and SIGHUP regression tests, with only a minor doc-contract nit noted.
Pull request overview
This PR fixes operator-facing config warnings that were previously emitted via eprintln! during config resolution (and therefore missed on the daemon SIGHUP reload path and in CLI flows without tracing). It introduces a structured “notice” channel collected during resolution and rendered by whichever caller owns an appropriate sink (node logging, CLI output, doctor findings).
Changes:
- Replace resolve-time
eprintln!warnings/info messages with recordedConfigNotices carried by a renamedConfigDiagnosticsaccumulator. - Emit recorded notices to
tracingafter subscriber installation at node startup and on successful SIGHUP reloads. - Extend CLI
config validateandnode doctorto render the returned notices; add unit + SIGHUP regression tests to pin reachability and severity.
File summaries
| File | Description |
|---|---|
| crates/common/src/config/errors.rs | Renames/extends the diagnostics accumulator to also store non-fatal ConfigNotices. |
| crates/common/src/config/mod.rs | Records notices during resolution and returns them from resolve_config as (ResolvedConfig, Vec<ConfigNotice>). |
| crates/node/src/runtime/reload.rs | Drains and emits notices only on successful reload; adds shared emit_config_notices. |
| crates/node/src/runtime/mod.rs | Re-exports emit_config_notices for use by startup command wiring. |
| crates/node/src/commands/mod.rs | Replays resolve-time notices via tracing immediately after init_tracing. |
| crates/node/tests/sighup_signal.rs | Adds regression test asserting SIGHUP reload notices reach the log stream and are suppressed on aborted reload. |
| crates/cli/src/commands/config.rs | Renders resolve notices under the validate summary, omitting the block when empty. |
| crates/cli/src/commands/doctor/config.rs | Converts notices into doctor findings with severity mapping Warn→Warn and Info→Pass. |
| crates/cli/tests/config_validate.rs | Adds coverage for validate-summary notice rendering and empty-notice behavior. |
| CHANGELOG.md | Documents the behavioral change and scope of converted notice sites. |
Review details
- Files reviewed: 10/10 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Coverage reportTotal: 82.77% (was 82.69%, ▲ +0.08%) — 74495/90003 lines
History
|
…g key Nine of the ten notice sites pass a dotted config label; the retired-env-var site passes the bare variable name, because that is the thing the operator set and must unset. The type said "dotted field label" unconditionally, which misleads exactly the consumers the field exists for — a JSON log stream or a `doctor` finding filtering on `field` would silently miss the retired-env-var notice, the one most likely to fire on an inherited orchestrator variable. The value is right: `resolve_network_into` already states the convention as "the label names the source the operator actually wrote". Only the doc was wrong. The existing test now says so at the assertion. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GqvbhAgEkq1XQ9Dm8TvLsq
…t gate The reload path emitted resolve-time notices between the phase-1 problem gate and the phase-2 fallible commits. A `fallible_commit` error returns before any `infallible_swap`, and `infallible_swap` is where the notice-bearing sections put their values — so a failing log-level setter logged a WARN about a security value the node never applied. Emission moves below the commit loop, where every gate that can abort has passed. Also from review of #1902: - `one_section` claimed every caller was a test shim; five were public, un-gated wrappers, one of which (`resolve_security`) discarded three notices. The four with no production caller are now `#[cfg(test)]`, leaving `resolve_discovery` — whose worker records none — as the sole production wrapper, and the docstring says so. - `warn_on_duplicate_origins` still used `tracing::warn!` on the pre-`init_tracing` resolve path. It records a notice, and its test now asserts the notice rather than leaving emission to code review. - Doctor findings put `field` in `detail` (fixing a `field: 0: message` title stutter) and derive a remediation from its shape: a dotted key is edited in the file, a bare env var unset in the environment. - A `Warn` moves doctor's exit status only under `--strict`; the CHANGELOG and two docstrings said otherwise. The CHANGELOG also now records that delivery follows the log filter, where raw stderr did not. Test gaps closed: a phase-2 abort leg (fails on the pre-fix ordering), a source guard on the startup replay ordering — positional, and invisible to any test that must install its own subscriber — end-to-end runs through both `decdn node doctor` and `decdn config validate`, default-value guards for dht/probe, the `(1..1024)` port edges, and discriminating message assertions so a swapped per-IP/per-peer body fails. The SIGHUP test now captures JSON and asserts `field` is a real event field, which is the property the design claims and rendered text cannot distinguish. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01JcJSKd5VZZjTFP6Hco3gQm
Closes #1902
The problem
resolve_security_intoemits its operator warnings witheprintln!, documented as load-bearing because notracingsubscriber exists atresolve_configtime. That reasoning holds for startup. It does not hold for the function's second caller,runtime::reload::SecuritySection::resolve, which runs on SIGHUP against a daemon whose subscriber has been live for hours.Concretely: an operator running
log_format = "json"and shipping only the structured stream setssecurity.max_tracked_sources = 0and SIGHUPs. The "rate-limit bookkeeping map is unbounded" warning goes to a raw stderr nobody is reading.infallible_swapdoes emit an event carrying the new value, but at info level and without the word "unbounded", so nothing alerts on it.The fix
The mechanism already existed and was half-built:
warn_retired_env_varsreturns the names it warned about specifically so a caller can propagate them, andresolve_configdiscarded the value into_retired.Resolvers now record
ConfigNotices on the shared bag. That bag is already threaded by&mutthrough every*_intoworker at startup and through every reloadable section on SIGHUP (ReloadableSection::resolve(&self, file, bag)), so the reload path is covered with zero signature changes to the trait or to any resolver. The caller renders them, because the caller is the only layer that knows which sink it has:decdn-nodestartuptracingevents, right afterinit_tracingadmin_v1_reloadtracingevents, on the success path onlydecdn config validatenotices (N):block under the field summarydecdn node doctorThe last two matter because
crates/clihas notracingdependency at all — the other half of whyeprintln!was chosen. Returning notices is what makes those paths renderable.Nothing became a hard error:
0 = unboundedis a documented escape hatch and an inherited orchestrator env var must not refuse boot. The problem was reachability, not severity.Scope
All ten former
eprintln!statements convert, not just the one on the reload path —resolve_network_into's--relay-urlnotice has the same reachability gap at startup, and a staleDECDN_RELAY_URLcollapsing a multi-entry failover list to one entry is a silent redundancy loss that reads as an unexplained outage months later.warn_retired_env_vars_withvalidate_port_layout_intonetwork.bind_port,observability.metrics_port,observability.admin_portresolve_network_intonetwork.relay_urlresolve_security_into.max_concurrent_handlers,.per_source_rate_per_secresolve_security_intosecurity.max_tracked_sourcesresolve_dht_intodht.rate_limit.max_tracked_per_{ip,peer}resolve_probe_intoprobe.rate_limit.max_tracked_per_{ip,peer}The severity split is the operator's, not the resolver's: an unbounded bookkeeping map moves
doctor's exit status, a deliberately disabled rate limit does not.Notable
ConfigErrorBag→ConfigDiagnostics. It carries both channels now, andbag.warn(…)on a type named…ErrorBagreads wrong. Mechanical; the only user outsidedecdn-commonisruntime/reload.rs.resolve_configreturns(ResolvedConfig, Vec<ConfigNotice>). Per the pre-launch rule, the signature changes rather than gaining a_with_noticessibling.resolve_configandreload. A config that does not resolve is not the one the operator is running, so its notices would describe nothing live. The SIGHUP test pins this.emit_config_noticeslives inruntime/reload.rsbesidewarn_ignored/warn_restart_required_sections, shared withcommands::run.init_tracingcould not simply move aboveresolve_config: its fallbackEnvFilteris built fromresolved.observability.log_level. Deferring the emit is the fix.Testing
sighup_signal.rs, reusing that file's capture harness (thread-localset_default,current_threadruntime, reload awaited inline — the three constraints its doc spells out). Asserts the notice reaches the buffer at WARN carrying "unbounded", and that an aborted reload emits nothing.mod.rspreviously described these as "other untestedeprintln!resolve warnings", and theresolve_securitytests hit the== 0branches without asserting anything about them.errors.rs: notices alone don't fail resolution;take_noticesdrains in insertion order and doesn't disturb the problem channel.doctormaps Warn→Warn and Info→Pass without moving exit status.cargo nextest run --workspace: 3233 passed.clippy --all-targets,fmt --check, andcargo doc -D warningsclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01GqvbhAgEkq1XQ9Dm8TvLsq