forked from NationTech/harmony
		
	wip: moving the install steps for grafana and prometheus into the trait installable<T>
This commit is contained in:
		
							parent
							
								
									f073b7e5fb
								
							
						
					
					
						commit
						58b6268989
					
				| @ -12,14 +12,17 @@ use crate::{ | |||||||
|     inventory::Inventory, |     inventory::Inventory, | ||||||
|     modules::{ |     modules::{ | ||||||
|         k3d::K3DInstallationScore, |         k3d::K3DInstallationScore, | ||||||
|         monitoring::kube_prometheus::crd::{ |         monitoring::{ | ||||||
|             crd_alertmanager_config::CRDPrometheus, |             grafana::{grafana::Grafana, helm::helm_grafana::grafana_helm_chart_score}, | ||||||
|             prometheus_operator::prometheus_operator_helm_chart_score, |             kube_prometheus::crd::{ | ||||||
|             rhob_alertmanager_config::RHOBObservability, |                 crd_alertmanager_config::CRDPrometheus, | ||||||
|  |                 prometheus_operator::prometheus_operator_helm_chart_score, | ||||||
|  |                 rhob_alertmanager_config::RHOBObservability, service_monitor::ServiceMonitor, | ||||||
|  |             }, | ||||||
|         }, |         }, | ||||||
|         prometheus::{ |         prometheus::{ | ||||||
|             k8s_prometheus_alerting_score::K8sPrometheusCRDAlertingScore, |             k8s_prometheus_alerting_score::K8sPrometheusCRDAlertingScore, | ||||||
|             prometheus::PrometheusApplicationMonitoring, rhob_alerting_score::RHOBAlertingScore, |             prometheus::PrometheusMonitoring, rhob_alerting_score::RHOBAlertingScore, | ||||||
|         }, |         }, | ||||||
|     }, |     }, | ||||||
|     score::Score, |     score::Score, | ||||||
| @ -86,7 +89,43 @@ impl K8sclient for K8sAnywhereTopology { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl PrometheusApplicationMonitoring<CRDPrometheus> for K8sAnywhereTopology { | impl Grafana for K8sAnywhereTopology { | ||||||
|  |     async fn ensure_grafana_operator_ready( | ||||||
|  |         &self, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |     ) -> Result<PreparationOutcome, PreparationError> { | ||||||
|  |         let client = self.k8s_client().await.unwrap(); | ||||||
|  |         let grafana_gvk = GroupVersionKind { | ||||||
|  |             group: "grafana.integreatly.org".to_string(), | ||||||
|  |             version: "v1beta1".to_string(), | ||||||
|  |             kind: "Grafana".to_string(), | ||||||
|  |         }; | ||||||
|  |         let name = "grafanas.grafana.integreatly.org"; | ||||||
|  |         let ns = "grafana"; | ||||||
|  | 
 | ||||||
|  |         let grafana_crd = client | ||||||
|  |             .get_resource_json_value(name, Some(ns), &grafana_gvk) | ||||||
|  |             .await; | ||||||
|  |         match grafana_crd { | ||||||
|  |             Ok(_) => { | ||||||
|  |                 return Ok(PreparationOutcome::Success { | ||||||
|  |                     details: "Found grafana CRDs in cluster".to_string(), | ||||||
|  |                 }); | ||||||
|  |             } | ||||||
|  |             Err(_) => { | ||||||
|  |                 return self | ||||||
|  |                     .install_grafana_operator(inventory, Some("grafana")) | ||||||
|  |                     .await; | ||||||
|  |             } | ||||||
|  |         }; | ||||||
|  |     } | ||||||
|  |     async fn install_grafana(&self) -> Result<PreparationOutcome, PreparationError> { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #[async_trait] | ||||||
|  | impl PrometheusMonitoring<CRDPrometheus> for K8sAnywhereTopology { | ||||||
|     async fn install_prometheus( |     async fn install_prometheus( | ||||||
|         &self, |         &self, | ||||||
|         sender: &CRDPrometheus, |         sender: &CRDPrometheus, | ||||||
| @ -101,7 +140,11 @@ impl PrometheusApplicationMonitoring<CRDPrometheus> for K8sAnywhereTopology { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         let result = self |         let result = self | ||||||
|             .get_k8s_prometheus_application_score(sender.clone(), receivers) |             .get_k8s_prometheus_application_score( | ||||||
|  |                 sender.clone(), | ||||||
|  |                 receivers, | ||||||
|  |                 Some(sender.service_monitor.clone()), | ||||||
|  |             ) | ||||||
|             .await |             .await | ||||||
|             .interpret(inventory, self) |             .interpret(inventory, self) | ||||||
|             .await; |             .await; | ||||||
| @ -117,10 +160,24 @@ impl PrometheusApplicationMonitoring<CRDPrometheus> for K8sAnywhereTopology { | |||||||
|             Err(err) => Err(PreparationError::new(err.to_string())), |             Err(err) => Err(PreparationError::new(err.to_string())), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     async fn ensure_prometheus_operator( | ||||||
|  |         &self, | ||||||
|  |         sender: &CRDPrometheus, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |     ) -> Result<PreparationOutcome, PreparationError> { | ||||||
|  |         let po_result = self.ensure_prometheus_operator(sender).await?; | ||||||
|  | 
 | ||||||
|  |         if po_result == PreparationOutcome::Noop { | ||||||
|  |             debug!("Skipping Prometheus CR installation due to missing operator."); | ||||||
|  |             return Ok(po_result); | ||||||
|  |         } else { | ||||||
|  |             todo!() | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl PrometheusApplicationMonitoring<RHOBObservability> for K8sAnywhereTopology { | impl PrometheusMonitoring<RHOBObservability> for K8sAnywhereTopology { | ||||||
|     async fn install_prometheus( |     async fn install_prometheus( | ||||||
|         &self, |         &self, | ||||||
|         sender: &RHOBObservability, |         sender: &RHOBObservability, | ||||||
| @ -154,6 +211,13 @@ impl PrometheusApplicationMonitoring<RHOBObservability> for K8sAnywhereTopology | |||||||
|             Err(err) => Err(PreparationError::new(err.to_string())), |             Err(err) => Err(PreparationError::new(err.to_string())), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     async fn ensure_prometheus_operator( | ||||||
|  |         &self, | ||||||
|  |         sender: &RHOBObservability, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |     ) -> Result<PreparationOutcome, PreparationError> { | ||||||
|  |         todo!() | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Serialize for K8sAnywhereTopology { | impl Serialize for K8sAnywhereTopology { | ||||||
| @ -253,12 +317,22 @@ impl K8sAnywhereTopology { | |||||||
|         &self, |         &self, | ||||||
|         sender: CRDPrometheus, |         sender: CRDPrometheus, | ||||||
|         receivers: Option<Vec<Box<dyn AlertReceiver<CRDPrometheus>>>>, |         receivers: Option<Vec<Box<dyn AlertReceiver<CRDPrometheus>>>>, | ||||||
|  |         service_monitors: Option<Vec<ServiceMonitor>>, | ||||||
|     ) -> K8sPrometheusCRDAlertingScore { |     ) -> K8sPrometheusCRDAlertingScore { | ||||||
|         K8sPrometheusCRDAlertingScore { |         if let Some(sm) = service_monitors { | ||||||
|             sender, |             return K8sPrometheusCRDAlertingScore { | ||||||
|             receivers: receivers.unwrap_or_default(), |                 sender, | ||||||
|             service_monitors: vec![], |                 receivers: receivers.unwrap_or_default(), | ||||||
|             prometheus_rules: vec![], |                 service_monitors: sm, | ||||||
|  |                 prometheus_rules: vec![], | ||||||
|  |             }; | ||||||
|  |         } else { | ||||||
|  |             return K8sPrometheusCRDAlertingScore { | ||||||
|  |                 sender, | ||||||
|  |                 receivers: receivers.unwrap_or_default(), | ||||||
|  |                 service_monitors: vec![], | ||||||
|  |                 prometheus_rules: vec![], | ||||||
|  |             }; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -527,6 +601,22 @@ impl K8sAnywhereTopology { | |||||||
|             details: "prometheus operator present in cluster".into(), |             details: "prometheus operator present in cluster".into(), | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     async fn install_grafana_operator( | ||||||
|  |         &self, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |         ns: Option<&str>, | ||||||
|  |     ) -> Result<PreparationOutcome, PreparationError> { | ||||||
|  |         let _grafana_operator_score = grafana_helm_chart_score(ns.unwrap(), true) | ||||||
|  |             .interpret(inventory, self) | ||||||
|  |             .await; | ||||||
|  |         Ok(PreparationOutcome::Success { | ||||||
|  |             details: format!( | ||||||
|  |                 "Successfully installed grafana operator in ns {}", | ||||||
|  |                 ns.unwrap() | ||||||
|  |             ), | ||||||
|  |         }) | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Debug)] | #[derive(Clone, Debug)] | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ use crate::{ | |||||||
|     topology::{HelmCommand, K8sclient, Topology, tenant::TenantManager}, |     topology::{HelmCommand, K8sclient, Topology, tenant::TenantManager}, | ||||||
| }; | }; | ||||||
| use crate::{ | use crate::{ | ||||||
|     modules::prometheus::prometheus::PrometheusApplicationMonitoring, |     modules::prometheus::prometheus::PrometheusMonitoring, | ||||||
|     topology::oberservability::monitoring::AlertReceiver, |     topology::oberservability::monitoring::AlertReceiver, | ||||||
| }; | }; | ||||||
| use async_trait::async_trait; | use async_trait::async_trait; | ||||||
| @ -40,7 +40,7 @@ impl< | |||||||
|         + TenantManager |         + TenantManager | ||||||
|         + K8sclient |         + K8sclient | ||||||
|         + MultiTargetTopology |         + MultiTargetTopology | ||||||
|         + PrometheusApplicationMonitoring<CRDPrometheus> |         + PrometheusMonitoring<CRDPrometheus> | ||||||
|         + Ingress |         + Ingress | ||||||
|         + std::fmt::Debug, |         + std::fmt::Debug, | ||||||
| > ApplicationFeature<T> for Monitoring | > ApplicationFeature<T> for Monitoring | ||||||
| @ -61,6 +61,7 @@ impl< | |||||||
|             sender: CRDPrometheus { |             sender: CRDPrometheus { | ||||||
|                 namespace: namespace.clone(), |                 namespace: namespace.clone(), | ||||||
|                 client: topology.k8s_client().await.unwrap(), |                 client: topology.k8s_client().await.unwrap(), | ||||||
|  |                 service_monitor: vec![], | ||||||
|             }, |             }, | ||||||
|             application: self.application.clone(), |             application: self.application.clone(), | ||||||
|             receivers: self.alert_receiver.clone(), |             receivers: self.alert_receiver.clone(), | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ use crate::{ | |||||||
|     topology::{HelmCommand, K8sclient, Topology, tenant::TenantManager}, |     topology::{HelmCommand, K8sclient, Topology, tenant::TenantManager}, | ||||||
| }; | }; | ||||||
| use crate::{ | use crate::{ | ||||||
|     modules::prometheus::prometheus::PrometheusApplicationMonitoring, |     modules::prometheus::prometheus::PrometheusMonitoring, | ||||||
|     topology::oberservability::monitoring::AlertReceiver, |     topology::oberservability::monitoring::AlertReceiver, | ||||||
| }; | }; | ||||||
| use async_trait::async_trait; | use async_trait::async_trait; | ||||||
| @ -42,7 +42,7 @@ impl< | |||||||
|         + MultiTargetTopology |         + MultiTargetTopology | ||||||
|         + Ingress |         + Ingress | ||||||
|         + std::fmt::Debug |         + std::fmt::Debug | ||||||
|         + PrometheusApplicationMonitoring<RHOBObservability>, |         + PrometheusMonitoring<RHOBObservability>, | ||||||
| > ApplicationFeature<T> for Monitoring | > ApplicationFeature<T> for Monitoring | ||||||
| { | { | ||||||
|     async fn ensure_installed( |     async fn ensure_installed( | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ use crate::{ | |||||||
|     modules::{ |     modules::{ | ||||||
|         application::Application, |         application::Application, | ||||||
|         monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus, |         monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus, | ||||||
|         prometheus::prometheus::PrometheusApplicationMonitoring, |         prometheus::prometheus::PrometheusMonitoring, | ||||||
|     }, |     }, | ||||||
|     score::Score, |     score::Score, | ||||||
|     topology::{PreparationOutcome, Topology, oberservability::monitoring::AlertReceiver}, |     topology::{PreparationOutcome, Topology, oberservability::monitoring::AlertReceiver}, | ||||||
| @ -24,9 +24,7 @@ pub struct ApplicationMonitoringScore { | |||||||
|     pub receivers: Vec<Box<dyn AlertReceiver<CRDPrometheus>>>, |     pub receivers: Vec<Box<dyn AlertReceiver<CRDPrometheus>>>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl<T: Topology + PrometheusApplicationMonitoring<CRDPrometheus>> Score<T> | impl<T: Topology + PrometheusMonitoring<CRDPrometheus>> Score<T> for ApplicationMonitoringScore { | ||||||
|     for ApplicationMonitoringScore |  | ||||||
| { |  | ||||||
|     fn create_interpret(&self) -> Box<dyn Interpret<T>> { |     fn create_interpret(&self) -> Box<dyn Interpret<T>> { | ||||||
|         Box::new(ApplicationMonitoringInterpret { |         Box::new(ApplicationMonitoringInterpret { | ||||||
|             score: self.clone(), |             score: self.clone(), | ||||||
| @ -47,7 +45,7 @@ pub struct ApplicationMonitoringInterpret { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl<T: Topology + PrometheusApplicationMonitoring<CRDPrometheus>> Interpret<T> | impl<T: Topology + PrometheusMonitoring<CRDPrometheus>> Interpret<T> | ||||||
|     for ApplicationMonitoringInterpret |     for ApplicationMonitoringInterpret | ||||||
| { | { | ||||||
|     async fn execute( |     async fn execute( | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ use crate::{ | |||||||
|         monitoring::kube_prometheus::crd::{ |         monitoring::kube_prometheus::crd::{ | ||||||
|             crd_alertmanager_config::CRDPrometheus, rhob_alertmanager_config::RHOBObservability, |             crd_alertmanager_config::CRDPrometheus, rhob_alertmanager_config::RHOBObservability, | ||||||
|         }, |         }, | ||||||
|         prometheus::prometheus::PrometheusApplicationMonitoring, |         prometheus::prometheus::PrometheusMonitoring, | ||||||
|     }, |     }, | ||||||
|     score::Score, |     score::Score, | ||||||
|     topology::{PreparationOutcome, Topology, oberservability::monitoring::AlertReceiver}, |     topology::{PreparationOutcome, Topology, oberservability::monitoring::AlertReceiver}, | ||||||
| @ -26,7 +26,7 @@ pub struct ApplicationRHOBMonitoringScore { | |||||||
|     pub receivers: Vec<Box<dyn AlertReceiver<RHOBObservability>>>, |     pub receivers: Vec<Box<dyn AlertReceiver<RHOBObservability>>>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl<T: Topology + PrometheusApplicationMonitoring<RHOBObservability>> Score<T> | impl<T: Topology + PrometheusMonitoring<RHOBObservability>> Score<T> | ||||||
|     for ApplicationRHOBMonitoringScore |     for ApplicationRHOBMonitoringScore | ||||||
| { | { | ||||||
|     fn create_interpret(&self) -> Box<dyn Interpret<T>> { |     fn create_interpret(&self) -> Box<dyn Interpret<T>> { | ||||||
| @ -49,7 +49,7 @@ pub struct ApplicationRHOBMonitoringInterpret { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl<T: Topology + PrometheusApplicationMonitoring<RHOBObservability>> Interpret<T> | impl<T: Topology + PrometheusMonitoring<RHOBObservability>> Interpret<T> | ||||||
|     for ApplicationRHOBMonitoringInterpret |     for ApplicationRHOBMonitoringInterpret | ||||||
| { | { | ||||||
|     async fn execute( |     async fn execute( | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								harmony/src/modules/monitoring/grafana/grafana.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								harmony/src/modules/monitoring/grafana/grafana.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | |||||||
|  | use async_trait::async_trait; | ||||||
|  | 
 | ||||||
|  | use crate::{ | ||||||
|  |     inventory::Inventory, | ||||||
|  |     topology::{PreparationError, PreparationOutcome}, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | #[async_trait] | ||||||
|  | pub trait Grafana { | ||||||
|  |     async fn ensure_grafana_operator_ready( | ||||||
|  |         &self, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |     ) -> Result<PreparationOutcome, PreparationError>; | ||||||
|  |     async fn install_grafana(&self) -> Result<PreparationOutcome, PreparationError>; | ||||||
|  | } | ||||||
| @ -1,25 +1,22 @@ | |||||||
| use non_blank_string_rs::NonBlankString; | use non_blank_string_rs::NonBlankString; | ||||||
| use std::str::FromStr; | use std::{collections::HashMap, str::FromStr}; | ||||||
| 
 | 
 | ||||||
| use crate::modules::helm::chart::HelmChartScore; | use crate::modules::helm::chart::HelmChartScore; | ||||||
| 
 | 
 | ||||||
| pub fn grafana_helm_chart_score(ns: &str) -> HelmChartScore { | pub fn grafana_helm_chart_score(ns: &str, scope: bool) -> HelmChartScore { | ||||||
|     let values = r#" |     let mut values_overrides = HashMap::new(); | ||||||
| rbac: |     values_overrides.insert( | ||||||
|   namespaced: true |         NonBlankString::from_str("namespaceScope").unwrap(), | ||||||
| sidecar: |         scope.to_string(), | ||||||
|   dashboards: |     ); | ||||||
|     enabled: true |  | ||||||
|         "#
 |  | ||||||
|     .to_string(); |  | ||||||
| 
 |  | ||||||
|     HelmChartScore { |     HelmChartScore { | ||||||
|         namespace: Some(NonBlankString::from_str(ns).unwrap()), |         namespace: Some(NonBlankString::from_str(ns).unwrap()), | ||||||
|         release_name: NonBlankString::from_str("grafana").unwrap(), |         release_name: NonBlankString::from_str("grafana").unwrap(), | ||||||
|         chart_name: NonBlankString::from_str("oci://ghcr.io/grafana/helm-charts/grafana").unwrap(), |         chart_name: NonBlankString::from_str("oci://ghcr.io/grafana/helm-charts/grafana-operator") | ||||||
|  |             .unwrap(), | ||||||
|         chart_version: None, |         chart_version: None, | ||||||
|         values_overrides: None, |         values_overrides: Some(values_overrides), | ||||||
|         values_yaml: Some(values.to_string()), |         values_yaml: None, | ||||||
|         create_namespace: true, |         create_namespace: true, | ||||||
|         install_only: true, |         install_only: true, | ||||||
|         repository: None, |         repository: None, | ||||||
|  | |||||||
| @ -1 +1,2 @@ | |||||||
|  | pub mod grafana; | ||||||
| pub mod helm; | pub mod helm; | ||||||
|  | |||||||
| @ -1,12 +1,25 @@ | |||||||
| use std::sync::Arc; | use std::sync::Arc; | ||||||
| 
 | 
 | ||||||
|  | use async_trait::async_trait; | ||||||
| use kube::CustomResource; | use kube::CustomResource; | ||||||
| use schemars::JsonSchema; | use schemars::JsonSchema; | ||||||
| use serde::{Deserialize, Serialize}; | use serde::{Deserialize, Serialize}; | ||||||
| 
 | 
 | ||||||
| use crate::topology::{ | use crate::{ | ||||||
|     k8s::K8sClient, |     interpret::{InterpretError, Outcome}, | ||||||
|     oberservability::monitoring::{AlertReceiver, AlertSender}, |     inventory::Inventory, | ||||||
|  |     modules::{ | ||||||
|  |         monitoring::{ | ||||||
|  |             grafana::grafana::Grafana, kube_prometheus::crd::service_monitor::ServiceMonitor, | ||||||
|  |         }, | ||||||
|  |         prometheus::prometheus::PrometheusMonitoring, | ||||||
|  |     }, | ||||||
|  |     topology::{ | ||||||
|  |         K8sclient, Topology, | ||||||
|  |         installable::Installable, | ||||||
|  |         k8s::K8sClient, | ||||||
|  |         oberservability::monitoring::{AlertReceiver, AlertSender}, | ||||||
|  |     }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | #[derive(CustomResource, Serialize, Deserialize, Debug, Clone, JsonSchema)] | ||||||
| @ -26,6 +39,7 @@ pub struct AlertmanagerConfigSpec { | |||||||
| pub struct CRDPrometheus { | pub struct CRDPrometheus { | ||||||
|     pub namespace: String, |     pub namespace: String, | ||||||
|     pub client: Arc<K8sClient>, |     pub client: Arc<K8sClient>, | ||||||
|  |     pub service_monitor: Vec<ServiceMonitor>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl AlertSender for CRDPrometheus { | impl AlertSender for CRDPrometheus { | ||||||
| @ -48,3 +62,24 @@ impl Serialize for Box<dyn AlertReceiver<CRDPrometheus>> { | |||||||
|         todo!() |         todo!() | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | #[async_trait] | ||||||
|  | impl<T: Topology + K8sclient + PrometheusMonitoring<CRDPrometheus> + Grafana> Installable<T> | ||||||
|  |     for CRDPrometheus | ||||||
|  | { | ||||||
|  |     async fn configure(&self, inventory: &Inventory, topology: &T) -> Result<(), InterpretError> { | ||||||
|  |         topology.ensure_grafana_operator_ready(inventory).await?; | ||||||
|  |         topology.ensure_prometheus_operator(self, inventory).await?; | ||||||
|  |         Ok(()) | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async fn ensure_installed( | ||||||
|  |         &self, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |         topology: &T, | ||||||
|  |     ) -> Result<(), InterpretError> { | ||||||
|  |         topology.install_grafana().await?; | ||||||
|  |         topology.install_prometheus(&self, inventory, None).await?; | ||||||
|  |         Ok(()) | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | |||||||
| @ -114,7 +114,7 @@ impl Prometheus { | |||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         if let Some(ns) = namespace.as_deref() { |         if let Some(ns) = namespace.as_deref() { | ||||||
|             grafana_helm_chart_score(ns) |             grafana_helm_chart_score(ns, false) | ||||||
|                 .interpret(inventory, topology) |                 .interpret(inventory, topology) | ||||||
|                 .await |                 .await | ||||||
|         } else { |         } else { | ||||||
|  | |||||||
| @ -39,7 +39,7 @@ use crate::{ | |||||||
| }; | }; | ||||||
| use harmony_types::id::Id; | use harmony_types::id::Id; | ||||||
| 
 | 
 | ||||||
| use super::prometheus::PrometheusApplicationMonitoring; | use super::prometheus::PrometheusMonitoring; | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Debug, Serialize)] | #[derive(Clone, Debug, Serialize)] | ||||||
| pub struct K8sPrometheusCRDAlertingScore { | pub struct K8sPrometheusCRDAlertingScore { | ||||||
| @ -49,7 +49,7 @@ pub struct K8sPrometheusCRDAlertingScore { | |||||||
|     pub prometheus_rules: Vec<RuleGroup>, |     pub prometheus_rules: Vec<RuleGroup>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl<T: Topology + K8sclient + PrometheusApplicationMonitoring<CRDPrometheus>> Score<T> | impl<T: Topology + K8sclient + PrometheusMonitoring<CRDPrometheus>> Score<T> | ||||||
|     for K8sPrometheusCRDAlertingScore |     for K8sPrometheusCRDAlertingScore | ||||||
| { | { | ||||||
|     fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> { |     fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> { | ||||||
| @ -75,7 +75,7 @@ pub struct K8sPrometheusCRDAlertingInterpret { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl<T: Topology + K8sclient + PrometheusApplicationMonitoring<CRDPrometheus>> Interpret<T> | impl<T: Topology + K8sclient + PrometheusMonitoring<CRDPrometheus>> Interpret<T> | ||||||
|     for K8sPrometheusCRDAlertingInterpret |     for K8sPrometheusCRDAlertingInterpret | ||||||
| { | { | ||||||
|     async fn execute( |     async fn execute( | ||||||
|  | |||||||
| @ -9,11 +9,17 @@ use crate::{ | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| pub trait PrometheusApplicationMonitoring<S: AlertSender> { | pub trait PrometheusMonitoring<S: AlertSender> { | ||||||
|     async fn install_prometheus( |     async fn install_prometheus( | ||||||
|         &self, |         &self, | ||||||
|         sender: &S, |         sender: &S, | ||||||
|         inventory: &Inventory, |         inventory: &Inventory, | ||||||
|         receivers: Option<Vec<Box<dyn AlertReceiver<S>>>>, |         receivers: Option<Vec<Box<dyn AlertReceiver<S>>>>, | ||||||
|     ) -> Result<PreparationOutcome, PreparationError>; |     ) -> Result<PreparationOutcome, PreparationError>; | ||||||
|  | 
 | ||||||
|  |     async fn ensure_prometheus_operator( | ||||||
|  |         &self, | ||||||
|  |         sender: &S, | ||||||
|  |         inventory: &Inventory, | ||||||
|  |     ) -> Result<PreparationOutcome, PreparationError>; | ||||||
| } | } | ||||||
|  | |||||||
| @ -38,7 +38,7 @@ use crate::{ | |||||||
| }; | }; | ||||||
| use harmony_types::id::Id; | use harmony_types::id::Id; | ||||||
| 
 | 
 | ||||||
| use super::prometheus::PrometheusApplicationMonitoring; | use super::prometheus::PrometheusMonitoring; | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Debug, Serialize)] | #[derive(Clone, Debug, Serialize)] | ||||||
| pub struct RHOBAlertingScore { | pub struct RHOBAlertingScore { | ||||||
| @ -48,8 +48,8 @@ pub struct RHOBAlertingScore { | |||||||
|     pub prometheus_rules: Vec<RuleGroup>, |     pub prometheus_rules: Vec<RuleGroup>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl<T: Topology + K8sclient + Ingress + PrometheusApplicationMonitoring<RHOBObservability>> | impl<T: Topology + K8sclient + Ingress + PrometheusMonitoring<RHOBObservability>> Score<T> | ||||||
|     Score<T> for RHOBAlertingScore |     for RHOBAlertingScore | ||||||
| { | { | ||||||
|     fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> { |     fn create_interpret(&self) -> Box<dyn crate::interpret::Interpret<T>> { | ||||||
|         Box::new(RHOBAlertingInterpret { |         Box::new(RHOBAlertingInterpret { | ||||||
| @ -74,8 +74,8 @@ pub struct RHOBAlertingInterpret { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[async_trait] | #[async_trait] | ||||||
| impl<T: Topology + K8sclient + Ingress + PrometheusApplicationMonitoring<RHOBObservability>> | impl<T: Topology + K8sclient + Ingress + PrometheusMonitoring<RHOBObservability>> Interpret<T> | ||||||
|     Interpret<T> for RHOBAlertingInterpret |     for RHOBAlertingInterpret | ||||||
| { | { | ||||||
|     async fn execute( |     async fn execute( | ||||||
|         &self, |         &self, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user