diff --git a/tembo-operator/src/cloudnativepg/hibernate.rs b/tembo-operator/src/cloudnativepg/hibernate.rs index c49df7f43..0b5d351a9 100644 --- a/tembo-operator/src/cloudnativepg/hibernate.rs +++ b/tembo-operator/src/cloudnativepg/hibernate.rs @@ -3,6 +3,7 @@ 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}; @@ -145,6 +146,22 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> } } + // Delete the IngressRouteTCP route for hibernated instances + if let Err(err) = delete_ingress_route_tcp( + Api::namespaced(client, &namespace), + &namespace, + &format!("{}-ro-0", cdb.name_any().as_str()), + ) + .await + { + warn!( + "Error deleting 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. diff --git a/tembo-operator/src/ingress.rs b/tembo-operator/src/ingress.rs index 1d7f67128..e1da9a22d 100644 --- a/tembo-operator/src/ingress.rs +++ b/tembo-operator/src/ingress.rs @@ -196,7 +196,7 @@ async fn apply_ingress_route_tcp( Ok(()) } -async fn delete_ingress_route_tcp( +pub async fn delete_ingress_route_tcp( ingress_route_tcp_api: Api, namespace: &str, ingress_route_tcp_name: &String,