mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
Remove time from Health Check Result (#549)
* change health check result to remove time * rename health check result * Update appmgr/src/dependencies.rs Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,7 @@ use crate::config::Config;
|
||||
use crate::context::RpcContext;
|
||||
use crate::db::model::CurrentDependencyInfo;
|
||||
use crate::s9pk::manifest::{Manifest, PackageId};
|
||||
use crate::status::health_check::{HealthCheckId, HealthCheckResult, HealthCheckResultVariant};
|
||||
use crate::status::health_check::{HealthCheckId, HealthCheckResult};
|
||||
use crate::status::{MainStatus, Status};
|
||||
use crate::util::Version;
|
||||
use crate::volume::Volumes;
|
||||
@@ -228,7 +228,7 @@ impl DependencyError {
|
||||
| MainStatus::Running { health, .. } => {
|
||||
let mut failures = BTreeMap::new();
|
||||
for (check, res) in health {
|
||||
if !matches!(res.result, HealthCheckResultVariant::Success)
|
||||
if !matches!(res, HealthCheckResult::Success)
|
||||
&& crate::db::DatabaseModel::new()
|
||||
.package_data()
|
||||
.idx_model(id)
|
||||
@@ -303,7 +303,7 @@ impl std::fmt::Display for DependencyError {
|
||||
} else {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
write!(f, "{} @ {} {}", check, res.time, res.result)?;
|
||||
write!(f, "{}: {}", check, res)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -94,54 +94,34 @@ impl HealthCheck {
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
Ok(HealthCheckResult {
|
||||
time: Utc::now(),
|
||||
result: match res {
|
||||
Ok(NoOutput) => HealthCheckResultVariant::Success,
|
||||
Err((59, _)) => HealthCheckResultVariant::Disabled,
|
||||
Err((60, _)) => HealthCheckResultVariant::Starting,
|
||||
Err((61, message)) => HealthCheckResultVariant::Loading { message },
|
||||
Err((_, error)) => HealthCheckResultVariant::Failure { error },
|
||||
},
|
||||
Ok(match res {
|
||||
Ok(NoOutput) => HealthCheckResult::Success,
|
||||
Err((59, _)) => HealthCheckResult::Disabled,
|
||||
Err((60, _)) => HealthCheckResult::Starting,
|
||||
Err((61, message)) => HealthCheckResult::Loading { message },
|
||||
Err((_, error)) => HealthCheckResult::Failure { error },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct HealthCheckResult {
|
||||
pub time: DateTime<Utc>,
|
||||
#[serde(flatten)]
|
||||
pub result: HealthCheckResultVariant,
|
||||
}
|
||||
impl HealthCheckResult {
|
||||
pub fn not_available() -> Self {
|
||||
HealthCheckResult {
|
||||
time: Utc::now(),
|
||||
result: HealthCheckResultVariant::Failure {
|
||||
error: "Health Check Status Not Available".to_owned(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[serde(tag = "result")]
|
||||
pub enum HealthCheckResultVariant {
|
||||
pub enum HealthCheckResult {
|
||||
Success,
|
||||
Disabled,
|
||||
Starting,
|
||||
Loading { message: String },
|
||||
Failure { error: String },
|
||||
}
|
||||
impl std::fmt::Display for HealthCheckResultVariant {
|
||||
impl std::fmt::Display for HealthCheckResult {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
HealthCheckResultVariant::Success => write!(f, "Succeeded"),
|
||||
HealthCheckResultVariant::Disabled => write!(f, "Disabled"),
|
||||
HealthCheckResultVariant::Starting => write!(f, "Starting"),
|
||||
HealthCheckResultVariant::Loading { message } => write!(f, "Loading ({})", message),
|
||||
HealthCheckResultVariant::Failure { error } => write!(f, "Failed ({})", error),
|
||||
HealthCheckResult::Success => write!(f, "Succeeded"),
|
||||
HealthCheckResult::Disabled => write!(f, "Disabled"),
|
||||
HealthCheckResult::Starting => write!(f, "Starting"),
|
||||
HealthCheckResult::Loading { message } => write!(f, "Loading ({})", message),
|
||||
HealthCheckResult::Failure { error } => write!(f, "Failed ({})", error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use futures::{FutureExt, StreamExt};
|
||||
use patch_db::{DbHandle, HasModel, Map, MapModel, ModelData};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use self::health_check::{HealthCheckId, HealthCheckResult};
|
||||
use self::health_check::HealthCheckId;
|
||||
use crate::context::RpcContext;
|
||||
use crate::db::model::{CurrentDependencyInfo, InstalledPackageDataEntryModel};
|
||||
use crate::dependencies::{
|
||||
@@ -17,7 +17,7 @@ use crate::dependencies::{
|
||||
use crate::manager::{Manager, Status as ManagerStatus};
|
||||
use crate::notifications::{notify, NotificationLevel, NotificationSubtype};
|
||||
use crate::s9pk::manifest::{Manifest, PackageId};
|
||||
use crate::status::health_check::HealthCheckResultVariant;
|
||||
use crate::status::health_check::HealthCheckResult;
|
||||
use crate::Error;
|
||||
|
||||
pub mod health_check;
|
||||
@@ -198,11 +198,8 @@ pub async fn check_all(ctx: &RpcContext) -> Result<(), Error> {
|
||||
let res = health
|
||||
.get(check)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| HealthCheckResult {
|
||||
result: HealthCheckResultVariant::Disabled,
|
||||
time: Utc::now(),
|
||||
});
|
||||
if !matches!(res.result, HealthCheckResultVariant::Success) {
|
||||
.unwrap_or_else(|| HealthCheckResult::Disabled);
|
||||
if !matches!(res, HealthCheckResult::Success) {
|
||||
failures.insert(check.clone(), res);
|
||||
}
|
||||
}
|
||||
@@ -329,8 +326,8 @@ impl MainStatus {
|
||||
.await?;
|
||||
let mut should_stop = false;
|
||||
for (check, res) in health {
|
||||
match &res.result {
|
||||
health_check::HealthCheckResultVariant::Failure { error }
|
||||
match &res {
|
||||
health_check::HealthCheckResult::Failure { error }
|
||||
if manifest
|
||||
.health_checks
|
||||
.0
|
||||
|
||||
4
compat/Cargo.lock
generated
4
compat/Cargo.lock
generated
@@ -874,9 +874,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "emver"
|
||||
version = "0.1.2"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79b2c25504998d1069f80a8082e3c558acd7c103a2f2399306b12ed06fec5db8"
|
||||
checksum = "ed260c4d7efaec031b9c4f6c4d3cf136e3df2bbfe50925800236f5e847f28704"
|
||||
dependencies = [
|
||||
"either",
|
||||
"fp-core",
|
||||
|
||||
2
patch-db
2
patch-db
Submodule patch-db updated: 44f7150bad...f0e6968a79
Reference in New Issue
Block a user