Skip to content

Commit

Permalink
Revert "Remove IngressRouteTCP for Stopped Instances" (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChuckHend authored Dec 11, 2024
1 parent 7e8df6d commit 37b53ab
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 73 deletions.
58 changes: 0 additions & 58 deletions tembo-operator/src/cloudnativepg/hibernate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use crate::cloudnativepg::clusters::{ClusterStatusConditions, ClusterStatusCondi
use crate::cloudnativepg::cnpg::{get_cluster, get_pooler, get_scheduled_backups};
use crate::cloudnativepg::poolers::Pooler;
use crate::cloudnativepg::scheduledbackups::ScheduledBackup;
use crate::ingress::delete_ingress_route_tcp;
use crate::Error;

use crate::{patch_cdb_status_merge, requeue_normal_with_jitter, Context};
Expand Down Expand Up @@ -146,63 +145,6 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc<Context>) ->
}
}

// Remove IngressRouteTCP route for stopped instances
let ingress_route_tcp_api = Api::namespaced(ctx.client.clone(), &namespace);
let prefix_read_only = format!("{}-ro-0", cdb.name_any().as_str());
if let Err(err) =
delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_read_only).await
{
warn!(
"Error deleting postgres ingress route for {}: {}",
cdb.name_any(),
err
);
return Err(Action::requeue(Duration::from_secs(300)));
}

let prefix_read_write = format!("{}-rw-0", cdb.name_any().as_str());
if let Err(err) = delete_ingress_route_tcp(
ingress_route_tcp_api.clone(),
&namespace,
&prefix_read_write,
)
.await
{
warn!(
"Error deleting postgres ingress route for {}: {}",
cdb.name_any(),
err
);
return Err(Action::requeue(Duration::from_secs(300)));
}

let prefix_pooler = format!("{}-pooler-0", cdb.name_any().as_str());
if let Err(err) =
delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_pooler).await
{
warn!(
"Error deleting postgres ingress route for {}: {}",
cdb.name_any(),
err
);
return Err(Action::requeue(Duration::from_secs(300)));
}

let extra_domain_names = cdb.spec.extra_domains_rw.clone().unwrap_or_default();
if !extra_domain_names.is_empty() {
let prefix_extra = format!("extra-{}-rw", cdb.name_any().as_str());
if let Err(err) =
delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_extra).await
{
warn!(
"Error deleting extra postgres ingress route for {}: {}",
cdb.name_any(),
err
);
return Err(Action::requeue(Duration::from_secs(300)));
}
}

// Stop CNPG reconciliation for hibernated instances.
// We should not stop CNPG reconciliation until hibernation is fully completed,
// as the instance may not finish hibernating otherwise.
Expand Down
2 changes: 1 addition & 1 deletion tembo-operator/src/ingress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async fn apply_ingress_route_tcp(
Ok(())
}

pub async fn delete_ingress_route_tcp(
async fn delete_ingress_route_tcp(
ingress_route_tcp_api: Api<IngressRouteTCP>,
namespace: &str,
ingress_route_tcp_name: &String,
Expand Down
14 changes: 0 additions & 14 deletions tembo-operator/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5808,7 +5808,6 @@ CREATE EVENT TRIGGER pgrst_watch
let test = TestCore::new(test_name).await;
let name = test.name.clone();
let pooler_name = format!("{}-pooler", name);
let namespace = test.namespace.clone();

// Generate very simple CoreDB JSON definitions. The first will be for
// initializing and starting the cluster, and the second for stopping
Expand Down Expand Up @@ -5851,19 +5850,6 @@ CREATE EVENT TRIGGER pgrst_watch
.await
.not());

// Assert that ingress routes are removed after hibernation

let client = test.client.clone();
let ingresses_tcp: Vec<IngressRouteTCP> =
list_resources(client.clone(), &name, &namespace, 0)
.await
.unwrap();
assert_eq!(
ingresses_tcp.len(),
0,
"Ingress routes should be removed after hibernation"
);

// Patch the cluster to start it up again, then check to ensure it
// actually did so. This proves hibernation can be reversed.

Expand Down

0 comments on commit 37b53ab

Please sign in to comment.