Skip to content

Commit

Permalink
requested changes 2
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajerin committed Nov 26, 2024
1 parent 83bd9d3 commit c55d796
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions tembo-operator/src/cloudnativepg/hibernate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc<Context>) ->
}

// Remove IngressRouteTCP route for stopped instances
let ingress_route_tcp_name = format!("{}-ro-0", cdb.name_any().as_str());
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, &namespace, &ingress_route_tcp_name).await
delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_read_only).await
{
warn!(
"Error deleting ingress route for {}: {}",
Expand All @@ -161,6 +160,34 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc<Context>) ->
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 extra ingress route for {}: {}",
cdb.name_any(),
err
);
return Err(Action::requeue(Duration::from_secs(300)));
}

let prefix_pooler = format!("{}-poller-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 pooler 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

0 comments on commit c55d796

Please sign in to comment.