fixes for demo
Some checks failed
Run Check Script / check (pull_request) Failing after 24s

This commit is contained in:
Jean-Gabriel Gill-Couture 2025-08-12 12:51:46 -04:00
parent 39aaf7c374
commit c46be79fc4
4 changed files with 32 additions and 10 deletions

View File

@ -4,6 +4,7 @@ use crate::modules::application::{Application, ApplicationFeature};
use crate::modules::monitoring::application_monitoring::application_monitoring_score::ApplicationMonitoringScore; use crate::modules::monitoring::application_monitoring::application_monitoring_score::ApplicationMonitoringScore;
use crate::modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus; use crate::modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus;
use crate::topology::MultiTargetTopology;
use crate::{ use crate::{
inventory::Inventory, inventory::Inventory,
modules::monitoring::{ modules::monitoring::{
@ -33,6 +34,7 @@ impl<
+ 'static + 'static
+ TenantManager + TenantManager
+ K8sclient + K8sclient
+ MultiTargetTopology
+ std::fmt::Debug + std::fmt::Debug
+ PrometheusApplicationMonitoring<CRDPrometheus>, + PrometheusApplicationMonitoring<CRDPrometheus>,
> ApplicationFeature<T> for Monitoring > ApplicationFeature<T> for Monitoring

View File

@ -1,9 +1,28 @@
use non_blank_string_rs::NonBlankString; use non_blank_string_rs::NonBlankString;
use std::str::FromStr; use std::str::FromStr;
use crate::modules::helm::chart::{HelmChartScore, HelmRepository}; use crate::{
modules::helm::chart::{HelmChartScore, HelmRepository},
topology::DeploymentTarget,
};
pub fn ntfy_helm_chart_score(
namespace: String,
host: String,
target: DeploymentTarget,
) -> HelmChartScore {
// TODO not actually the correct logic, this should be fixed by using an ingresss which is the
// correct k8s standard.
//
// Another option is to delegate to the topology the ingress technology it wants to use Route,
// Ingress or other
let route_enabled = match target {
DeploymentTarget::LocalDev => false,
DeploymentTarget::Staging => true,
DeploymentTarget::Production => true,
};
let ingress_enabled = !route_enabled;
pub fn ntfy_helm_chart_score(namespace: String, host: String) -> HelmChartScore {
let values = format!( let values = format!(
r#" r#"
replicaCount: 1 replicaCount: 1
@ -28,10 +47,10 @@ service:
port: 8080 port: 8080
ingress: ingress:
enabled: false enabled: {ingress_enabled}
route: route:
enabled: true enabled: {route_enabled}
host: {host} host: {host}
autoscaling: autoscaling:

View File

@ -11,7 +11,7 @@ use crate::{
inventory::Inventory, inventory::Inventory,
modules::monitoring::ntfy::helm::ntfy_helm_chart::ntfy_helm_chart_score, modules::monitoring::ntfy::helm::ntfy_helm_chart::ntfy_helm_chart_score,
score::Score, score::Score,
topology::{HelmCommand, K8sclient, Topology, k8s::K8sClient}, topology::{k8s::K8sClient, HelmCommand, K8sclient, MultiTargetTopology, Topology},
}; };
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
@ -20,7 +20,7 @@ pub struct NtfyScore {
pub host: String, pub host: String,
} }
impl<T: Topology + HelmCommand + K8sclient> Score<T> for NtfyScore { impl<T: Topology + HelmCommand + K8sclient + MultiTargetTopology> Score<T> for NtfyScore {
fn create_interpret(&self) -> Box<dyn Interpret<T>> { fn create_interpret(&self) -> Box<dyn Interpret<T>> {
Box::new(NtfyInterpret { Box::new(NtfyInterpret {
score: self.clone(), score: self.clone(),
@ -77,7 +77,7 @@ impl NtfyInterpret {
vec![ vec![
"sh", "sh",
"-c", "-c",
format!("NTFY_PASSWORD={password} ntfy user add --role={role} {username}") format!("NTFY_PASSWORD={password} ntfy user add --role={role} --ignore-exists {username}")
.as_str(), .as_str(),
], ],
) )
@ -89,13 +89,13 @@ impl NtfyInterpret {
/// We need a ntfy interpret to wrap the HelmChartScore in order to run the score, and then bootstrap the config inside ntfy /// We need a ntfy interpret to wrap the HelmChartScore in order to run the score, and then bootstrap the config inside ntfy
#[async_trait] #[async_trait]
impl<T: Topology + HelmCommand + K8sclient> Interpret<T> for NtfyInterpret { impl<T: Topology + HelmCommand + K8sclient + MultiTargetTopology> Interpret<T> for NtfyInterpret {
async fn execute( async fn execute(
&self, &self,
inventory: &Inventory, inventory: &Inventory,
topology: &T, topology: &T,
) -> Result<Outcome, InterpretError> { ) -> Result<Outcome, InterpretError> {
ntfy_helm_chart_score(self.score.namespace.clone(), self.score.host.clone()) ntfy_helm_chart_score(self.score.namespace.clone(), self.score.host.clone(), topology.current_target())
.interpret(inventory, topology) .interpret(inventory, topology)
.await?; .await?;

View File

@ -166,7 +166,8 @@ impl K8sPrometheusCRDAlertingInterpret {
let install_output = Command::new("helm") let install_output = Command::new("helm")
.args([ .args([
"install", "upgrade",
"--install",
&chart_name, &chart_name,
tgz_path.to_str().unwrap(), tgz_path.to_str().unwrap(),
"--namespace", "--namespace",