From 4f4c3b0d6ef06464bf47be224c48631953935ce7 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 30 Oct 2025 12:35:23 +0100 Subject: [PATCH] Improve notification behavior during startup and recovery Fix notification issues for better operational experience: Startup Notification Suppression: - Suppress notifications for transitions from Status::Unknown during agent/server startup - Prevents notification spam when services transition from Unknown to Warning/Critical on restart - Only real status changes (not initial discovery) trigger notifications - Maintains alerting for actual service state changes after startup Recovery Notification Refinement: - Recovery notifications only sent when ALL services reach OK status - Individual service recoveries suppressed if other services still have problems - Ensures recovery notifications indicate complete system health restoration - Prevents premature celebration when partial recoveries occur Result: Clean startup experience without false alerts and meaningful recovery notifications that truly indicate full system health restoration. Bump version to v0.1.48 --- Cargo.lock | 6 +++--- agent/Cargo.toml | 2 +- agent/src/status/mod.rs | 10 ++++++---- dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6db155..d378998 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,7 +270,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" [[package]] name = "cm-dashboard" -version = "0.1.46" +version = "0.1.47" dependencies = [ "anyhow", "chrono", @@ -291,7 +291,7 @@ dependencies = [ [[package]] name = "cm-dashboard-agent" -version = "0.1.46" +version = "0.1.47" dependencies = [ "anyhow", "async-trait", @@ -314,7 +314,7 @@ dependencies = [ [[package]] name = "cm-dashboard-shared" -version = "0.1.46" +version = "0.1.47" dependencies = [ "chrono", "serde", diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 3c445b8..0837e93 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.47" +version = "0.1.48" edition = "2021" [dependencies] diff --git a/agent/src/status/mod.rs b/agent/src/status/mod.rs index b6aaada..6f6ada8 100644 --- a/agent/src/status/mod.rs +++ b/agent/src/status/mod.rs @@ -272,11 +272,13 @@ impl HostStatusManager { /// Check if a status change is significant enough for notification fn is_significant_change(&self, old_status: Status, new_status: Status) -> bool { match (old_status, new_status) { - // Always notify on problems + // Don't notify on transitions from Unknown (startup/restart scenario) + (Status::Unknown, _) => false, + // Always notify on problems (but not from Unknown) (_, Status::Warning) | (_, Status::Critical) => true, // Only notify on recovery if it's from a problem state to OK and all services are OK (Status::Warning | Status::Critical, Status::Ok) => self.current_host_status == Status::Ok, - // Don't notify on startup or other transitions + // Don't notify on other transitions _ => false, } } @@ -374,8 +376,8 @@ impl HostStatusManager { details.push('\n'); } - // Show recoveries - if !recovery_changes.is_empty() { + // Show recoveries only if host status is now OK (all services recovered) + if !recovery_changes.is_empty() && aggregated.host_status_final == Status::Ok { details.push_str(&format!("✅ RECOVERIES ({}):\n", recovery_changes.len())); for change in recovery_changes { details.push_str(&format!(" {}\n", change)); diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 5f85797..fec138a 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.47" +version = "0.1.48" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 3aa91b1..f77f2c7 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.47" +version = "0.1.48" edition = "2021" [dependencies]