simpler check to see if a crd exists + cleanup
All checks were successful
Run Check Script / check (pull_request) Successful in -41s
All checks were successful
Run Check Script / check (pull_request) Successful in -41s
This commit is contained in:
parent
064f6d88ba
commit
a8394cda47
@ -275,6 +275,7 @@ impl K8sAnywhereTopology {
|
||||
.args(["-c", "kubectl get crd -A | grep -i prometheuses"])
|
||||
.status()
|
||||
.map_err(|e| InterpretError::new(format!("could not connect to cluster: {}", e)))?;
|
||||
|
||||
if !status.success() {
|
||||
if let Some(Some(k8s_state)) = self.k8s_state.get() {
|
||||
match k8s_state.source {
|
||||
|
@ -6,7 +6,7 @@ use async_trait::async_trait;
|
||||
use kube::api::ObjectMeta;
|
||||
use log::{debug, info};
|
||||
use serde::Serialize;
|
||||
use tokio::process::Command;
|
||||
use std::process::Command;
|
||||
|
||||
use crate::modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus;
|
||||
use crate::modules::monitoring::kube_prometheus::crd::crd_default_rules::build_default_application_rules;
|
||||
@ -117,12 +117,13 @@ impl<T: Topology + K8sclient + PrometheusApplicationMonitoring<CRDPrometheus>> I
|
||||
|
||||
impl K8sPrometheusCRDAlertingInterpret {
|
||||
async fn crd_exists(&self, crd: &str) -> bool {
|
||||
let output = Command::new("kubectl")
|
||||
.args(["get", "crd", crd])
|
||||
.output()
|
||||
.await;
|
||||
let status = Command::new("sh")
|
||||
.args(["-c", "kubectl get crd -A | grep -i", crd])
|
||||
.status()
|
||||
.map_err(|e| InterpretError::new(format!("could not connect to cluster: {}", e)))
|
||||
.unwrap();
|
||||
|
||||
matches!(output, Ok(o) if o.status.success())
|
||||
status.success()
|
||||
}
|
||||
|
||||
async fn install_chart(
|
||||
@ -136,9 +137,8 @@ impl K8sPrometheusCRDAlertingInterpret {
|
||||
debug!("Using temp directory: {}", temp_path.display());
|
||||
let chart = format!("{}/{}", chart_path, chart_name);
|
||||
let pull_output = Command::new("helm")
|
||||
.args(&["pull", &chart, "--destination", temp_path.to_str().unwrap()])
|
||||
.args(["pull", &chart, "--destination", temp_path.to_str().unwrap()])
|
||||
.output()
|
||||
.await
|
||||
.map_err(|e| InterpretError::new(format!("Helm pull error: {}", e)))?;
|
||||
|
||||
if !pull_output.status.success() {
|
||||
@ -165,7 +165,7 @@ impl K8sPrometheusCRDAlertingInterpret {
|
||||
debug!("Installing chart from: {}", tgz_path.display());
|
||||
|
||||
let install_output = Command::new("helm")
|
||||
.args(&[
|
||||
.args([
|
||||
"install",
|
||||
&chart_name,
|
||||
tgz_path.to_str().unwrap(),
|
||||
@ -176,7 +176,6 @@ impl K8sPrometheusCRDAlertingInterpret {
|
||||
"--atomic",
|
||||
])
|
||||
.output()
|
||||
.await
|
||||
.map_err(|e| InterpretError::new(format!("Helm install error: {}", e)))?;
|
||||
|
||||
if !install_output.status.success() {
|
||||
@ -209,13 +208,11 @@ impl K8sPrometheusCRDAlertingInterpret {
|
||||
"https://grafana.github.io/helm-charts",
|
||||
])
|
||||
.output()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let _ = Command::new("helm")
|
||||
.args(["repo", "update"])
|
||||
.output()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let output = Command::new("helm")
|
||||
@ -230,7 +227,6 @@ impl K8sPrometheusCRDAlertingInterpret {
|
||||
"namespaceScope=true",
|
||||
])
|
||||
.output()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if !output.status.success() {
|
||||
|
Loading…
Reference in New Issue
Block a user