diff --git a/harmony/src/domain/topology/ingress.rs b/harmony/src/domain/topology/ingress.rs index d1cd929..d27eb48 100644 --- a/harmony/src/domain/topology/ingress.rs +++ b/harmony/src/domain/topology/ingress.rs @@ -1,11 +1,7 @@ +use crate::topology::{PreparationError, k8s::K8sClient}; +use async_trait::async_trait; use std::sync::Arc; -use async_trait::async_trait; - -use crate::{ - interpret::InterpretError, - topology::{PreparationError, k8s::K8sClient}, -}; #[async_trait] pub trait Ingress { async fn get_domain(&self, client: Arc) -> Result; diff --git a/harmony/src/domain/topology/k8s_anywhere.rs b/harmony/src/domain/topology/k8s_anywhere.rs index 54f91ee..571f9ea 100644 --- a/harmony/src/domain/topology/k8s_anywhere.rs +++ b/harmony/src/domain/topology/k8s_anywhere.rs @@ -577,21 +577,38 @@ impl TenantManager for K8sAnywhereTopology { impl Ingress for K8sAnywhereTopology { //TODO this is specifically for openshift/okd which violates the k8sanywhere idea async fn get_domain(&self, client: Arc) -> Result { - self.openshift_ingress_operator_available().await?; + if let Some(Some(k8s_state)) = self.k8s_state.get() { + match k8s_state.source { + K8sSource::LocalK3d => Ok("localhost".to_string()), + K8sSource::Kubeconfig => { + self.openshift_ingress_operator_available().await?; - let gvk = GroupVersionKind { - group: "operator.openshift.io".into(), - version: "v1".into(), - kind: "IngressController".into(), - }; - let ic = client - .get_resource_json_value("default", Some("openshift-ingress-operator"), &gvk) - .await - .map_err(|_| PreparationError::new("Failed to fetch IngressController".to_string()))?; + let gvk = GroupVersionKind { + group: "operator.openshift.io".into(), + version: "v1".into(), + kind: "IngressController".into(), + }; + let ic = client + .get_resource_json_value( + "default", + Some("openshift-ingress-operator"), + &gvk, + ) + .await + .map_err(|_| { + PreparationError::new("Failed to fetch IngressController".to_string()) + })?; - match ic.data["status"]["domain"].as_str() { - Some(domain) => Ok(domain.to_string()), - None => Err(PreparationError::new("Could not find domain".to_string())), + match ic.data["status"]["domain"].as_str() { + Some(domain) => Ok(domain.to_string()), + None => Err(PreparationError::new("Could not find domain".to_string())), + } + } + } + } else { + Err(PreparationError::new( + "Cannot get domain: unable to detect K8s state".to_string(), + )) } } } diff --git a/harmony/src/modules/application/features/helm_argocd_score.rs b/harmony/src/modules/application/features/helm_argocd_score.rs index 52ab6f6..f49ca0d 100644 --- a/harmony/src/modules/application/features/helm_argocd_score.rs +++ b/harmony/src/modules/application/features/helm_argocd_score.rs @@ -13,7 +13,8 @@ use crate::{ modules::helm::chart::{HelmChartScore, HelmRepository}, score::Score, topology::{ - ingress::Ingress, k8s::K8sClient, HelmCommand, K8sclient, PreparationError, PreparationOutcome, Topology + HelmCommand, K8sclient, PreparationError, PreparationOutcome, Topology, ingress::Ingress, + k8s::K8sClient, }, }; use harmony_types::id::Id; diff --git a/harmony/src/modules/prometheus/rhob_alerting_score.rs b/harmony/src/modules/prometheus/rhob_alerting_score.rs index 06aa33f..71a3596 100644 --- a/harmony/src/modules/prometheus/rhob_alerting_score.rs +++ b/harmony/src/modules/prometheus/rhob_alerting_score.rs @@ -51,8 +51,8 @@ pub struct RHOBAlertingScore { pub prometheus_rules: Vec, } -impl> Score - for RHOBAlertingScore +impl> + Score for RHOBAlertingScore { fn create_interpret(&self) -> Box> { Box::new(RHOBAlertingInterpret { @@ -77,8 +77,8 @@ pub struct RHOBAlertingInterpret { } #[async_trait] -impl> Interpret - for RHOBAlertingInterpret +impl> + Interpret for RHOBAlertingInterpret { async fn execute( &self, @@ -90,7 +90,7 @@ impl( + async fn install_prometheus( &self, inventory: &Inventory, topology: &T, @@ -274,6 +274,7 @@ impl RHOBAlertingInterpret { .apply(&stack, Some(&self.sender.namespace.clone())) .await .map_err(|e| InterpretError::new(e.to_string()))?; + let domain = topology.get_domain(client.clone()).await?; let name = format!("{}-alert-manager", self.sender.namespace.clone()); let backend_service = format!("{}-alert-manager", self.sender.namespace.clone());