Skip to content

Commit

Permalink
fix operator integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhudson committed Dec 16, 2023
1 parent ad75960 commit 2c707cb
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 282 deletions.
32 changes: 8 additions & 24 deletions tembo-operator/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use crate::{
extensions::{database_queries::list_config_params, reconcile_extensions},
ingress::{reconcile_extra_postgres_ing_route_tcp, reconcile_ip_allowlist_middleware},
network_policies::reconcile_network_policies,
postgres_exporter::reconcile_prom_configmap,
postgres_exporter::reconcile_metrics_configmap,
trunk::{extensions_that_require_load, reconcile_trunk_configmap},
};
use rand::Rng;
Expand Down Expand Up @@ -214,16 +214,15 @@ impl CoreDB {

reconcile_app_services(self, ctx.clone()).await?;

if self.spec.postgresExporterEnabled
&& self
.spec
.metrics
.as_ref()
.and_then(|m| m.queries.as_ref())
.is_some()
if self
.spec
.metrics
.as_ref()
.and_then(|m| m.queries.as_ref())
.is_some()
{
debug!("Reconciling prometheus configmap");
reconcile_prom_configmap(self, client.clone(), &ns)
reconcile_metrics_configmap(self, client.clone(), &ns)
.await
.map_err(|e| {
error!("Error reconciling prometheus configmap: {:?}", e);
Expand All @@ -238,21 +237,6 @@ impl CoreDB {
Action::requeue(Duration::from_secs(300))
})?;

// Postgres exporter connection info
if self.spec.postgresExporterEnabled {
let _ = reconcile_postgres_role_secret(
self,
ctx.clone(),
"postgres_exporter",
&format!("{}-exporter", name.clone()),
)
.await
.map_err(|e| {
error!("Error reconciling postgres exporter secret: {:?}", e);
Action::requeue(Duration::from_secs(300))
})?;
}

let _ =
reconcile_postgres_role_secret(self, ctx.clone(), "readonly", &format!("{}-ro", name.clone()))
.await
Expand Down
2 changes: 1 addition & 1 deletion tembo-operator/src/postgres_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl FromStr for Usage {
}
}

pub async fn reconcile_prom_configmap(cdb: &CoreDB, client: Client, ns: &str) -> Result<(), Error> {
pub async fn reconcile_metrics_configmap(cdb: &CoreDB, client: Client, ns: &str) -> Result<(), Error> {
// set custom pg-prom metrics in configmap values if they are specified
let coredb_name = cdb
.metadata
Expand Down
Loading

0 comments on commit 2c707cb

Please sign in to comment.