replace todo with actual notify call

This commit is contained in:
Keagan McClelland
2021-09-14 16:44:20 -06:00
committed by Aiden McClelland
parent c5724f40b7
commit f4d184ccb0

View File

@@ -13,6 +13,7 @@ use crate::context::RpcContext;
use crate::db::model::CurrentDependencyInfo; use crate::db::model::CurrentDependencyInfo;
use crate::dependencies::DependencyError; use crate::dependencies::DependencyError;
use crate::manager::{Manager, Status as ManagerStatus}; use crate::manager::{Manager, Status as ManagerStatus};
use crate::notifications::{notify, NotificationLevel, NotificationSubtype};
use crate::s9pk::manifest::{Manifest, PackageId}; use crate::s9pk::manifest::{Manifest, PackageId};
use crate::status::health_check::HealthCheckResultVariant; use crate::status::health_check::HealthCheckResultVariant;
use crate::Error; use crate::Error;
@@ -267,21 +268,35 @@ impl MainStatus {
&manifest.volumes, &manifest.volumes,
) )
.await?; .await?;
let mut should_stop = false;
for (check, res) in health { for (check, res) in health {
if matches!( match &res.result {
res.result, health_check::HealthCheckResultVariant::Failure { error }
health_check::HealthCheckResultVariant::Failure { .. } if manifest
) && manifest .health_checks
.health_checks .0
.0 .get(check)
.get(check) .map(|hc| hc.critical)
.map(|hc| hc.critical) .unwrap_or_default() =>
.unwrap_or_default() {
{ notify(
todo!("emit notification"); &ctx.secret_store,
*self = MainStatus::Stopping; &ctx.db,
Some(manifest.id.clone()),
NotificationLevel::Error,
String::from("Critical Health Check Failed"),
format!("{} was shut down because a health check required for its operation failed\n{}", manifest.title, error),
NotificationSubtype::General
)
.await?;
should_stop = true;
}
_ => (),
} }
} }
if should_stop {
*self = MainStatus::Stopping;
}
} }
_ => (), _ => (),
} }