swarm-queue-based lifecycle notices, replacing push_todo(MANAGER_AGENT)
This commit is contained in:
parent
10a294a2f8
commit
e44ea9d8d4
12 changed files with 388 additions and 142 deletions
|
|
@ -47,10 +47,6 @@ use crate::stats::sweep_health::{self, SweepHealth};
|
|||
/// other silently re-tunes the swarm's definition of "quiet".
|
||||
pub const PUBLISH_INTERVAL: Duration = Duration::from_mins(1);
|
||||
|
||||
/// Env var prefix for this daemon's swarm-queue credentials — see
|
||||
/// [`swarm_queue_client::QueueConfig::from_env`]. All four or none.
|
||||
const ENV_PREFIX: &str = "HIVE_C0RE";
|
||||
|
||||
/// Consecutive failed publishes before the dashboard banners.
|
||||
///
|
||||
/// At [`PUBLISH_INTERVAL`] this is ~3 minutes of genuine failure, so a
|
||||
|
|
@ -59,43 +55,15 @@ const FAILURES_BEFORE_BANNER: u32 = 3;
|
|||
|
||||
/// Start the publish loop, if this deployment wired up a swarm queue.
|
||||
///
|
||||
/// Absent queue config is the ordinary case — most hives are not in a
|
||||
/// swarm — so it is an `info` and not a warning. A *half*-set environment
|
||||
/// is a different thing entirely and [`swarm_queue_client::QueueConfig::from_env`]
|
||||
/// makes it a hard error; it is bannered here rather than swallowed,
|
||||
/// because the failure it otherwise produces is a hive that looks fine
|
||||
/// and silently never reports.
|
||||
/// The connect itself is shared with every other swarm-queue consumer in
|
||||
/// this process — see [`crate::swarm_queue`] for why one connection and
|
||||
/// not one per consumer, and for where "no queue configured" vs. "queue
|
||||
/// configured but unreachable" gets bannered. This function only decides
|
||||
/// whether *status* has anything to offer once a client exists.
|
||||
pub fn spawn(
|
||||
coord: std::sync::Arc<crate::coordinator::Coordinator>,
|
||||
mut shutdown: tokio::sync::watch::Receiver<bool>,
|
||||
) {
|
||||
let cfg = match swarm_queue_client::QueueConfig::from_env(ENV_PREFIX) {
|
||||
Ok(Some(cfg)) => cfg,
|
||||
Ok(None) => {
|
||||
tracing::info!("no swarm queue configured; this hive offers no status upward");
|
||||
return;
|
||||
}
|
||||
Err(e) => {
|
||||
// A one-shot startup step with no later retry to clear it —
|
||||
// exactly what `set_boot_warning` is for. The fix is a
|
||||
// redeploy, which restarts this process anyway.
|
||||
//
|
||||
// `chain`, not `{:#}`: this is the queue client's own error
|
||||
// type, whose Display ignores the alternate flag, so `{:#}`
|
||||
// would show only "swarm queue is half-configured" and drop
|
||||
// which variables are missing.
|
||||
crate::warnings::set_boot_warning(
|
||||
"swarm_status_config",
|
||||
"warn",
|
||||
format!(
|
||||
"swarm status publishing is off: {}",
|
||||
swarm_queue_client::chain(&e)
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let Some(hive) = crate::container_view::hive_swarm_names().0 else {
|
||||
crate::warnings::set_boot_warning(
|
||||
"swarm_status_config",
|
||||
|
|
@ -107,26 +75,11 @@ pub fn spawn(
|
|||
};
|
||||
|
||||
tokio::spawn(async move {
|
||||
// `retry_on_initial_connect` inside, so this returns a client
|
||||
// that may not be connected yet rather than failing on a queue
|
||||
// that comes up second. The publish below is what discovers that,
|
||||
// and it is already the thing that reports it.
|
||||
let client = match swarm_queue_client::connect(cfg).await {
|
||||
Ok(client) => client,
|
||||
Err(e) => {
|
||||
// `chain` for the same reason as above: without it this
|
||||
// banner reads "connecting to the swarm queue at <url>"
|
||||
// and drops the nats error that says why.
|
||||
crate::warnings::set_boot_warning(
|
||||
"swarm_status_config",
|
||||
"warn",
|
||||
format!(
|
||||
"swarm status publishing is off: {}",
|
||||
swarm_queue_client::chain(&e)
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
let Some(client) = crate::swarm_queue::client().await else {
|
||||
// Absent or failed — either way already handled (an `info`
|
||||
// log or a `swarm_queue_config` banner) by the shared
|
||||
// connector; nothing left to report here.
|
||||
return;
|
||||
};
|
||||
|
||||
// The hive's ONE queue connection, now serving both directions:
|
||||
|
|
|
|||
Loading…
Reference in a new issue