sweep: dedupe matrix ensure_all banner closure
This commit is contained in:
parent
b889f403d5
commit
84ea7b8e7d
1 changed files with 17 additions and 24 deletions
|
|
@ -401,6 +401,21 @@ async fn cmd_serve(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/// Banner message for a failing matrix `ensure_all` sweep, shared by
|
||||||
|
/// both the initial and periodic `record_err` call sites below so the
|
||||||
|
/// wording can't drift between them.
|
||||||
|
fn matrix_sweep_banner(ctx: sweep_health::SweepFailure) -> String {
|
||||||
|
let age = ctx.since_last_ok.map_or_else(
|
||||||
|
|| "no success this session".to_owned(),
|
||||||
|
|d| format!("last ok {} ago", sweep_health::fmt_age(d)),
|
||||||
|
);
|
||||||
|
format!(
|
||||||
|
"matrix user/space sweep failing ({} consecutive, {age}) \
|
||||||
|
— some agents may be missing matrix accounts, space membership, \
|
||||||
|
or chat-room invites",
|
||||||
|
ctx.consecutive
|
||||||
|
)
|
||||||
|
}
|
||||||
// Matrix user sweep: same shape — ensure every container has
|
// Matrix user sweep: same shape — ensure every container has
|
||||||
// an account on the local matrix-tuwunel homeserver with an
|
// an account on the local matrix-tuwunel homeserver with an
|
||||||
// access_token persisted to `<state>/matrix-token`. No-op when
|
// access_token persisted to `<state>/matrix-token`. No-op when
|
||||||
|
|
@ -422,18 +437,7 @@ async fn cmd_serve(
|
||||||
if matrix::ensure_all().await {
|
if matrix::ensure_all().await {
|
||||||
health.record_ok();
|
health.record_ok();
|
||||||
} else {
|
} else {
|
||||||
health.record_err(|ctx| {
|
health.record_err(matrix_sweep_banner);
|
||||||
let age = ctx.since_last_ok.map_or_else(
|
|
||||||
|| "no success this session".to_owned(),
|
|
||||||
|d| format!("last ok {} ago", sweep_health::fmt_age(d)),
|
|
||||||
);
|
|
||||||
format!(
|
|
||||||
"matrix user/space sweep failing ({} consecutive, {age}) \
|
|
||||||
— some agents may be missing matrix accounts, space membership, \
|
|
||||||
or chat-room invites",
|
|
||||||
ctx.consecutive
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
|
|
@ -441,18 +445,7 @@ async fn cmd_serve(
|
||||||
if matrix::ensure_all().await {
|
if matrix::ensure_all().await {
|
||||||
health.record_ok();
|
health.record_ok();
|
||||||
} else {
|
} else {
|
||||||
health.record_err(|ctx| {
|
health.record_err(matrix_sweep_banner);
|
||||||
let age = ctx.since_last_ok.map_or_else(
|
|
||||||
|| "no success this session".to_owned(),
|
|
||||||
|d| format!("last ok {} ago", sweep_health::fmt_age(d)),
|
|
||||||
);
|
|
||||||
format!(
|
|
||||||
"matrix user/space sweep failing ({} consecutive, {age}) \
|
|
||||||
— some agents may be missing matrix accounts, space membership, \
|
|
||||||
or chat-room invites",
|
|
||||||
ctx.consecutive
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ = matrix_shutdown.changed() => {
|
_ = matrix_shutdown.changed() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue