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
Some checks failed
Run Check Script / check (pull_request) Has been cancelled

This commit is contained in:
Willem 2025-10-20 15:31:06 -04:00
parent c0d54a4466
commit ce91ee0168
3 changed files with 10 additions and 19 deletions

View File

@ -585,21 +585,12 @@ impl K8sAnywhereTopology {
receivers: Option<Vec<Box<dyn AlertReceiver<CRDPrometheus>>>>, receivers: Option<Vec<Box<dyn AlertReceiver<CRDPrometheus>>>>,
service_monitors: Option<Vec<ServiceMonitor>>, service_monitors: Option<Vec<ServiceMonitor>>,
) -> K8sPrometheusCRDAlertingScore { ) -> K8sPrometheusCRDAlertingScore {
if let Some(sm) = service_monitors { return K8sPrometheusCRDAlertingScore {
return K8sPrometheusCRDAlertingScore { sender,
sender, receivers: receivers.unwrap_or_default(),
receivers: receivers.unwrap_or_default(), service_monitors: service_monitors.unwrap_or_default(),
service_monitors: sm, prometheus_rules: vec![],
prometheus_rules: vec![], };
};
} else {
return K8sPrometheusCRDAlertingScore {
sender,
receivers: receivers.unwrap_or_default(),
service_monitors: vec![],
prometheus_rules: vec![],
};
}
} }
async fn openshift_ingress_operator_available(&self) -> Result<(), PreparationError> { 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) let _grafana_operator_score = grafana_helm_chart_score(namespace, namespace_scope)
.interpret(inventory, self) .interpret(inventory, self)
.await; .await
.map_err(|e| PreparationError::new(e.to_string()));
Ok(PreparationOutcome::Success { Ok(PreparationOutcome::Success {
details: format!( details: format!(
"Successfully installed grafana operator in ns {}", "Successfully installed grafana operator in ns {}",

View File

@ -1,3 +1,4 @@
use harmony_macros::hurl;
use non_blank_string_rs::NonBlankString; use non_blank_string_rs::NonBlankString;
use std::{collections::HashMap, str::FromStr}; 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, install_only: true,
repository: Some(HelmRepository::new( repository: Some(HelmRepository::new(
"grafana".to_string(), "grafana".to_string(),
url::Url::parse("https://grafana.github.io/helm-charts").unwrap(), hurl!("https://grafana.github.io/helm-charts"),
true, true,
)), )),
} }

View File

@ -467,8 +467,6 @@ impl K8sPrometheusCRDAlertingInterpret {
match_labels: label.clone(), match_labels: label.clone(),
match_expressions: vec![], 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 namespace = self.sender.namespace.clone();
let json_data = GrafanaDatasourceJsonData { let json_data = GrafanaDatasourceJsonData {
time_interval: Some("5s".to_string()), time_interval: Some("5s".to_string()),