Skip to content

feat(node): expose admin_v1_reload to trigger hot-reload over loopback HTTP #373

Closed

Description

@alpergundogdu

Companion to #367 (SIGHUP hot-reload).

Why

#367 wired SIGHUP to call RuntimeReloadState::reload() for the two reloadable fields (payment.rate_per_mb, observability.log_level). Two real wins from also exposing this on the admin HTTP surface:

  1. Structured response. SIGHUP is fire-and-forget — operators have to inspect logs to learn whether the reload applied or which fields changed. An RPC method can return { status: "reloaded", ... } or { status: "error", reason: ... } directly.
  2. Non-Unix-y orchestrators. systemd users keep using ExecReload= to send SIGHUP. Windows hosts, some PaaS, container orchestrators, and operator scripts that don't speak signals get a programmatic path.

Fits the existing local-admin-http appendix pattern exactly — admin_v1_health and admin_v1_peersList already expose health + peer-table reads on the same loopback surface; reload joins as the third operator-local control action.

Shape

New jsonrpsee method on the existing admin_v1 namespace:

#[method(name = "reload")]
async fn reload(&self) -> RpcResult<ReloadResponse>;

pub struct ReloadResponse {
    pub status: ReloadStatus,                  // Reloaded | Noop | Error
    pub rate_per_mb: u64,                      // current value after reload
    pub log_level: String,                     // current value after reload
    pub error: Option<String>,                 // present iff status == Error
}

Both SIGHUP and admin_v1_reload call the same RuntimeReloadState::reload() — the existing mutex inside that function already serialises concurrent reloads, so racing paths just queue.

CLI ride-along: decdn node reload [--config <path>] calls the RPC and prints the response (matching the decdn node health / decdn node peers pattern).

Edge cases

  • No config path in use. SIGHUP today logs "SIGHUP received but no config file path is in use; ignoring". The RPC method returns { status: "error", reason: "no config path in use" } (HTTP 200 with a structured body — not a transport-level error).
  • Reload fails (parse / validation / mutex poison). RPC returns the same structured error response. The existing reload contract preserves previous values on error; that contract is unchanged.
  • Concurrent SIGHUP + RPC. Serialised by the mutex inside RuntimeReloadState::reload() — both calls succeed; the second one is a noop diff if nothing changed between them.

Files

File Change
crates/node/src/admin.rs New ReloadResponse + ReloadStatus types; add reload to AdminRpc trait; impl in AdminRpcImpl
crates/node/src/admin.rs (AdminState) Carry Arc<RuntimeReloadState> and Option<PathBuf> config path
crates/node/src/runtime/mod.rs Pass the new state into AdminState::new
crates/node/src/commands/node.rs New reload CLI subcommand
crates/node/src/cli/node.rs Surface the new subcommand
Tests Roundtrip; success/error/noop variants; concurrent-with-SIGHUP serialisation

Acceptance

  • admin_v1_reload returns a structured ReloadResponse on the loopback admin port.
  • decdn node reload exits 0 on success, non-zero on error, prints the response.
  • SIGHUP and the RPC share RuntimeReloadState::reload(); both can be exercised concurrently without races (test).
  • No config-path → structured error response, not a panic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions