From ce91ee01685c48b81e46440e171440c92723577b Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 20 Oct 2025 15:31:06 -0400 Subject: [PATCH] fix: removed dead code, mapped error from grafana operator to preparation error rather than ignoring it, modified k8sprometheus score to unwrap_or_default() service monitors --- harmony/src/domain/topology/k8s_anywhere.rs | 24 +++++++------------ .../monitoring/grafana/helm/helm_grafana.rs | 3 ++- .../k8s_prometheus_alerting_score.rs | 2 -- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/harmony/src/domain/topology/k8s_anywhere.rs b/harmony/src/domain/topology/k8s_anywhere.rs index e45b65f..cf56333 100644 --- a/harmony/src/domain/topology/k8s_anywhere.rs +++ b/harmony/src/domain/topology/k8s_anywhere.rs @@ -585,21 +585,12 @@ impl K8sAnywhereTopology { receivers: Option>>>, service_monitors: Option>, ) -> K8sPrometheusCRDAlertingScore { - if let Some(sm) = service_monitors { - return K8sPrometheusCRDAlertingScore { - sender, - receivers: receivers.unwrap_or_default(), - service_monitors: sm, - prometheus_rules: vec![], - }; - } else { - return K8sPrometheusCRDAlertingScore { - sender, - receivers: receivers.unwrap_or_default(), - service_monitors: vec![], - prometheus_rules: vec![], - }; - } + return K8sPrometheusCRDAlertingScore { + sender, + receivers: receivers.unwrap_or_default(), + service_monitors: service_monitors.unwrap_or_default(), + prometheus_rules: vec![], + }; } async fn openshift_ingress_operator_available(&self) -> Result<(), PreparationError> { @@ -882,7 +873,8 @@ impl K8sAnywhereTopology { } let _grafana_operator_score = grafana_helm_chart_score(namespace, namespace_scope) .interpret(inventory, self) - .await; + .await + .map_err(|e| PreparationError::new(e.to_string())); Ok(PreparationOutcome::Success { details: format!( "Successfully installed grafana operator in ns {}", diff --git a/harmony/src/modules/monitoring/grafana/helm/helm_grafana.rs b/harmony/src/modules/monitoring/grafana/helm/helm_grafana.rs index 2965ada..c9ccacb 100644 --- a/harmony/src/modules/monitoring/grafana/helm/helm_grafana.rs +++ b/harmony/src/modules/monitoring/grafana/helm/helm_grafana.rs @@ -1,3 +1,4 @@ +use harmony_macros::hurl; use non_blank_string_rs::NonBlankString; use std::{collections::HashMap, str::FromStr}; @@ -20,7 +21,7 @@ pub fn grafana_helm_chart_score(ns: &str, namespace_scope: bool) -> HelmChartSco install_only: true, repository: Some(HelmRepository::new( "grafana".to_string(), - url::Url::parse("https://grafana.github.io/helm-charts").unwrap(), + hurl!("https://grafana.github.io/helm-charts"), true, )), } diff --git a/harmony/src/modules/prometheus/k8s_prometheus_alerting_score.rs b/harmony/src/modules/prometheus/k8s_prometheus_alerting_score.rs index d7dca5e..7093ee8 100644 --- a/harmony/src/modules/prometheus/k8s_prometheus_alerting_score.rs +++ b/harmony/src/modules/prometheus/k8s_prometheus_alerting_score.rs @@ -467,8 +467,6 @@ impl K8sPrometheusCRDAlertingInterpret { match_labels: label.clone(), match_expressions: vec![], }; - // let mut json_data = BTreeMap::new(); - // json_data.insert("timeInterval".to_string(), "5s".to_string()); let namespace = self.sender.namespace.clone(); let json_data = GrafanaDatasourceJsonData { time_interval: Some("5s".to_string()),