Skip to content

Commit

Permalink
Only fence restore pods if they need a trunk install
Browse files Browse the repository at this point in the history
  • Loading branch information
sjmiller609 committed Jun 6, 2024
1 parent d5215fd commit 58b98eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tembo-operator/src/cloudnativepg/cnpg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ use kube::{
use std::{collections::BTreeMap, sync::Arc};
use tokio::time::Duration;
use tracing::{debug, error, info, instrument, warn};
use crate::extensions::install::find_trunk_installs_to_pod;

pub struct PostgresConfig {
pub postgres_parameters: Option<BTreeMap<String, String>>,
Expand Down Expand Up @@ -887,7 +888,10 @@ async fn pods_to_fence(cdb: &CoreDB, ctx: Arc<Context>) -> Result<Vec<String>, A
let mut pod_names_to_fence = Vec::new();
for i in 1..=cdb.spec.replicas {
let pod_name = format!("{}-{}", &cdb.name_any(), i);
pod_names_to_fence.push(pod_name);
let trunk_installs = find_trunk_installs_to_pod(cdb, &pod_name);
if !trunk_installs.is_empty() {
pod_names_to_fence.push(pod_name);
}
}

debug!(
Expand Down
2 changes: 1 addition & 1 deletion tembo-operator/src/extensions/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn find_trunk_installs_to_remove_from_status(cdb: &CoreDB) -> Vec<String> {
/// This function also needs to define a lifetime, since we are only returning a reference to
/// TrunkInstall, which is owned by CoreDB we only need to define a lifetime for CoreDB
#[instrument(skip(cdb, pod_name) fields(trace_id))]
fn find_trunk_installs_to_pod<'a>(cdb: &'a CoreDB, pod_name: &str) -> Vec<&'a TrunkInstall> {
pub fn find_trunk_installs_to_pod<'a>(cdb: &'a CoreDB, pod_name: &str) -> Vec<&'a TrunkInstall> {
debug!(
"Checking for trunk installs to install on pod {} for {}",
pod_name,
Expand Down

0 comments on commit 58b98eb

Please sign in to comment.