From 94c5251920c3f820cc8b91fbf27e1fe1a5cb292c Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Wed, 11 Dec 2024 15:44:54 -0500 Subject: [PATCH 1/5] Re-add Josh's commit Signed-off-by: Ian Stanton --- tembo-operator/src/cloudnativepg/hibernate.rs | 58 +++++++++++++++++++ tembo-operator/src/ingress.rs | 2 +- tembo-operator/tests/integration_tests.rs | 14 +++++ 3 files changed, 73 insertions(+), 1 deletion(-) diff --git a/tembo-operator/src/cloudnativepg/hibernate.rs b/tembo-operator/src/cloudnativepg/hibernate.rs index c49df7f43..340ed019e 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,63 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> } } + // 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. 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, diff --git a/tembo-operator/tests/integration_tests.rs b/tembo-operator/tests/integration_tests.rs index 53f00a9d0..d570ca3bf 100644 --- a/tembo-operator/tests/integration_tests.rs +++ b/tembo-operator/tests/integration_tests.rs @@ -5808,6 +5808,7 @@ 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 @@ -5850,6 +5851,19 @@ CREATE EVENT TRIGGER pgrst_watch .await .not()); + // Assert that ingress routes are removed after hibernation + + let client = test.client.clone(); + let ingresses_tcp: Vec = + 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. From 85371c56ae92358f4c789731e65abffe0b3b6913 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Wed, 11 Dec 2024 16:16:31 -0500 Subject: [PATCH 2/5] Remove IngressRoutes for stopped instances Signed-off-by: Ian Stanton --- tembo-operator/src/cloudnativepg/hibernate.rs | 41 ++++++++++++++---- tembo-operator/src/ingress.rs | 42 +++++++++++++++++++ tembo-operator/tests/integration_tests.rs | 17 ++++++-- 3 files changed, 90 insertions(+), 10 deletions(-) diff --git a/tembo-operator/src/cloudnativepg/hibernate.rs b/tembo-operator/src/cloudnativepg/hibernate.rs index 340ed019e..c7a8b279e 100644 --- a/tembo-operator/src/cloudnativepg/hibernate.rs +++ b/tembo-operator/src/cloudnativepg/hibernate.rs @@ -3,7 +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::ingress::{delete_ingress_route, delete_ingress_route_tcp}; use crate::Error; use crate::{patch_cdb_status_merge, requeue_normal_with_jitter, Context}; @@ -14,17 +14,17 @@ use serde_json::json; use k8s_openapi::api::apps::v1::Deployment; +use super::clusters::Cluster; use crate::app_service::manager::get_appservice_deployment_objects; use crate::cloudnativepg::cnpg_utils::{ get_pooler_instances, patch_cluster_merge, patch_pooler_merge, patch_scheduled_backup_merge, removed_stalled_backups, }; +use crate::ingress_route_crd::IngressRoute; use std::sync::Arc; use std::time::Duration; use tracing::{debug, error, info, warn}; -use super::clusters::Cluster; - /// Resolves hibernation in the Cluster and related services of the CoreDB /// /// If the cluster is in spec.stop state, this will activate the CNPG hibernation @@ -146,6 +146,33 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> } } + // Remove IngressRoutes for stopped instances + let ingress_route_api: Api = Api::namespaced(ctx.client.clone(), &namespace); + if let Err(err) = delete_ingress_route(ingress_route_api.clone(), &namespace, &name).await { + warn!( + "Error deleting app service IngressRoute for {}: {}", + cdb.name_any(), + err + ); + return Err(Action::requeue(Duration::from_secs(300))); + } + + let metrics_ing_route_name = format!("{}-metrics", cdb.name_any().as_str()); + if let Err(err) = delete_ingress_route( + ingress_route_api.clone(), + &namespace, + &metrics_ing_route_name, + ) + .await + { + warn!( + "Error deleting metrics IngressRoute for {}: {}", + cdb.name_any(), + err + ); + return Err(Action::requeue(Duration::from_secs(300))); + } + // 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()); @@ -153,7 +180,7 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_read_only).await { warn!( - "Error deleting postgres ingress route for {}: {}", + "Error deleting postgres IngressRouteTCP for {}: {}", cdb.name_any(), err ); @@ -169,7 +196,7 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> .await { warn!( - "Error deleting postgres ingress route for {}: {}", + "Error deleting postgres IngressRouteTCP for {}: {}", cdb.name_any(), err ); @@ -181,7 +208,7 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_pooler).await { warn!( - "Error deleting postgres ingress route for {}: {}", + "Error deleting postgres IngressRouteTCP for {}: {}", cdb.name_any(), err ); @@ -195,7 +222,7 @@ pub async fn reconcile_cluster_hibernation(cdb: &CoreDB, ctx: &Arc) -> delete_ingress_route_tcp(ingress_route_tcp_api.clone(), &namespace, &prefix_extra).await { warn!( - "Error deleting extra postgres ingress route for {}: {}", + "Error deleting extra postgres IngressRouteTCP for {}: {}", cdb.name_any(), err ); diff --git a/tembo-operator/src/ingress.rs b/tembo-operator/src/ingress.rs index e1da9a22d..0568c8e6f 100644 --- a/tembo-operator/src/ingress.rs +++ b/tembo-operator/src/ingress.rs @@ -13,6 +13,7 @@ use kube::{ use regex::Regex; use std::sync::Arc; +use crate::ingress_route_crd::IngressRoute; use crate::{ apis::coredb_types::CoreDB, errors::OperatorError, @@ -196,6 +197,47 @@ async fn apply_ingress_route_tcp( Ok(()) } +pub async fn delete_ingress_route( + ingress_route_api: Api, + namespace: &str, + ingress_route_name: &String, +) -> Result<(), OperatorError> { + // Check if the resource exists + if ingress_route_api + .get(&ingress_route_name.clone()) + .await + .is_ok() + { + // If it exists, proceed with the deletion + let delete_parameters = DeleteParams::default(); + match ingress_route_api + .delete(&ingress_route_name.clone(), &delete_parameters) + .await + { + Ok(_) => { + info!( + "Deleted IngressRoute {}.{}", + ingress_route_name.clone(), + namespace + ); + } + Err(e) => { + error!( + "Failed to delete IngressRoute {}.{}: {}", + ingress_route_name, namespace, e + ); + return Err(OperatorError::IngressRouteError); + } + } + } else { + debug!( + "IngressRoute {}.{} was not found. Assuming it's already deleted.", + ingress_route_name, namespace + ); + } + Ok(()) +} + pub async fn delete_ingress_route_tcp( ingress_route_tcp_api: Api, namespace: &str, diff --git a/tembo-operator/tests/integration_tests.rs b/tembo-operator/tests/integration_tests.rs index d570ca3bf..743741bab 100644 --- a/tembo-operator/tests/integration_tests.rs +++ b/tembo-operator/tests/integration_tests.rs @@ -5851,8 +5851,7 @@ CREATE EVENT TRIGGER pgrst_watch .await .not()); - // Assert that ingress routes are removed after hibernation - + // Assert that IngressRouteTCPs are removed after hibernation let client = test.client.clone(); let ingresses_tcp: Vec = list_resources(client.clone(), &name, &namespace, 0) @@ -5861,7 +5860,19 @@ CREATE EVENT TRIGGER pgrst_watch assert_eq!( ingresses_tcp.len(), 0, - "Ingress routes should be removed after hibernation" + "IngressRouteTCPs should be removed after hibernation" + ); + + // Assert that IngressRoutes are removed after hibernation + let client = test.client.clone(); + let ingress_routes: Vec = + list_resources(client.clone(), &name, &namespace, 0) + .await + .unwrap(); + assert_eq!( + ingress_routes.len(), + 0, + "IngressRoutes should be removed after hibernation" ); // Patch the cluster to start it up again, then check to ensure it From 4db71749992c4fce95ad6002623b9ebc5689357a Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Wed, 11 Dec 2024 22:47:59 -0500 Subject: [PATCH 3/5] Assert IngressRoutes and IngressRouteTCPs are present Signed-off-by: Ian Stanton --- tembo-operator/tests/integration_tests.rs | 27 +++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tembo-operator/tests/integration_tests.rs b/tembo-operator/tests/integration_tests.rs index 743741bab..a611b8349 100644 --- a/tembo-operator/tests/integration_tests.rs +++ b/tembo-operator/tests/integration_tests.rs @@ -709,7 +709,7 @@ mod test { R::DynamicType: Default, { let api: Api = Api::namespaced(client, namespace); - let lp = ListParams::default().labels(format!("coredb.io/name={}", cdb_name).as_str()); + let lp = ListParams::default(); let retry = 15; let mut passed_retry = false; let mut resource_list: Vec = Vec::new(); @@ -721,10 +721,11 @@ mod test { break; } else { println!( - "ns:{}.cdb:{} Found {}, expected {}", + "ns:{}.cdb:{} Found {} {}, expected {}", namespace, cdb_name, resources.items.len(), + std::any::type_name::(), num_expected ); } @@ -5884,6 +5885,28 @@ CREATE EVENT TRIGGER pgrst_watch assert!(status_running(&test.coredbs, &name).await); assert!(pooler_status_running(&test.poolers, &pooler_name).await); + // Assert that IngressRouteTCPs are created after starting + let ingress_tcps: Vec = + list_resources(client.clone(), &name, &namespace, 2) + .await + .unwrap(); + assert_eq!( + ingress_tcps.len(), + 2, + "IngressRouteTCPs should be created after starting" + ); + + // Assert that IngressRoutes are created after starting + let ingress_routes: Vec = + list_resources(client.clone(), &name, &namespace, 1) + .await + .unwrap(); + assert_eq!( + ingress_routes.len(), + 1, + "IngressRoutes should be created after starting" + ); + test.teardown().await; } From b1600dcfedd3ec974f6efad2a561b97e251e1fcc Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Thu, 12 Dec 2024 12:09:59 -0500 Subject: [PATCH 4/5] Add test for hibernate with app service Signed-off-by: Ian Stanton --- tembo-operator/tests/integration_tests.rs | 162 +++++++++++++++++++++- 1 file changed, 160 insertions(+), 2 deletions(-) diff --git a/tembo-operator/tests/integration_tests.rs b/tembo-operator/tests/integration_tests.rs index a611b8349..eedd88f13 100644 --- a/tembo-operator/tests/integration_tests.rs +++ b/tembo-operator/tests/integration_tests.rs @@ -5885,7 +5885,7 @@ CREATE EVENT TRIGGER pgrst_watch assert!(status_running(&test.coredbs, &name).await); assert!(pooler_status_running(&test.poolers, &pooler_name).await); - // Assert that IngressRouteTCPs are created after starting + // Assert there are 2 IngressRouteTCPs created after starting. 1 for postgres and 1 for the pooler let ingress_tcps: Vec = list_resources(client.clone(), &name, &namespace, 2) .await @@ -5896,7 +5896,7 @@ CREATE EVENT TRIGGER pgrst_watch "IngressRouteTCPs should be created after starting" ); - // Assert that IngressRoutes are created after starting + // Assert there is 1 IngressRoute created after starting. This is the IngressRoute for metrics let ingress_routes: Vec = list_resources(client.clone(), &name, &namespace, 1) .await @@ -5910,6 +5910,164 @@ CREATE EVENT TRIGGER pgrst_watch test.teardown().await; } + #[tokio::test] + #[ignore] + async fn functional_test_hibernate_with_app_service() { + let test_name = "test-hibernate-cnpg-with-app-service"; + 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 with an app service, and the second for stopping + // it. We'll use a single replica to ensure _all_ parts of the cluster + // are affected by hibernate. + + let cluster_start = serde_json::json!({ + "apiVersion": API_VERSION, + "kind": "CoreDB", + "metadata": { + "name": name + }, + "spec": { + "replicas": 1, + "stop": false, + "connectionPooler": { + "enabled": true + }, + "appServices": [ + { + "name": "postgrest", + "image": "postgrest/postgrest:v10.0.0", + "env": [ + { + "name": "PGRST_DB_URI", + "valueFromPlatform": "ReadWriteConnection" + }, + { + "name": "PGRST_DB_SCHEMA", + "value": "public" + }, + { + "name": "PGRST_DB_ANON_ROLE", + "value": "postgres" + } + ], + "routing": [ + { + "port": 3000, + "ingressPath": "/", + "ingressType": "http" + } + ], + "resources": { + "requests": { + "cpu": "100m", + "memory": "256Mi" + }, + "limits": { + "cpu": "100m", + "memory": "256Mi" + } + } + } + ] + } + }); + + let mut cluster_stop = cluster_start.clone(); + cluster_stop["spec"]["stop"] = serde_json::json!(true); + + // Begin by starting the cluster and validating that it worked. + // We need this here as initial iterations of the hibernate code + // prevented the cluster from starting. + + let _ = test.set_cluster_def(&cluster_start).await; + assert!(status_running(&test.coredbs, &name).await); + assert!(pooler_status_running(&test.poolers, &pooler_name).await); + + // Assert there are 3 pods running: 1 for postgres, 1 for the pooler, and 1 for the app service + let pods: Api = Api::namespaced(test.client.clone(), &namespace); + let pods_list = pods.list(&Default::default()).await.unwrap(); + assert_eq!(pods_list.items.len(), 3); + + // Stop the cluster and check to make sure it's not running to ensure + // hibernate is doing its job. + + let _ = test.set_cluster_def(&cluster_stop).await; + let _ = wait_until_status_not_running(&test.coredbs, &name).await; + assert!(status_running(&test.coredbs, &name).await.not()); + assert!(pooler_status_running(&test.poolers, &pooler_name) + .await + .not()); + + // Assert there are no pods running + let pods_list = pods.list(&Default::default()).await.unwrap(); + assert_eq!(pods_list.items.len(), 0); + + // Assert that IngressRouteTCPs are removed after hibernation + let client = test.client.clone(); + let ingresses_tcp: Vec = + list_resources(client.clone(), &name, &namespace, 0) + .await + .unwrap(); + assert_eq!( + ingresses_tcp.len(), + 0, + "IngressRouteTCPs should be removed after hibernation" + ); + + // Assert that IngressRoutes are removed after hibernation + let client = test.client.clone(); + let ingress_routes: Vec = + list_resources(client.clone(), &name, &namespace, 0) + .await + .unwrap(); + assert_eq!( + ingress_routes.len(), + 0, + "IngressRoutes 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. + + println!("Starting cluster after hibernation"); + println!("CoreDB: {}", cluster_start); + let _ = test.set_cluster_def(&cluster_start).await; + assert!(status_running(&test.coredbs, &name).await); + assert!(pooler_status_running(&test.poolers, &pooler_name).await); + + // Assert there are 3 pods running: 1 for postgres, 1 for the pooler, and 1 for the app service + let pods_list = pods.list(&Default::default()).await.unwrap(); + assert_eq!(pods_list.items.len(), 3); + + // Assert there are 2 IngressRouteTCPs created after starting. 1 for postgres and 1 for the pooler + let ingress_tcps: Vec = + list_resources(client.clone(), &name, &namespace, 2) + .await + .unwrap(); + assert_eq!( + ingress_tcps.len(), + 2, + "IngressRouteTCPs should be created after starting" + ); + + // Assert there are 2 IngressRoutes created after starting. 1 for metrics and 1 for the app service + let ingress_routes: Vec = + list_resources(client.clone(), &name, &namespace, 2) + .await + .unwrap(); + assert_eq!( + ingress_routes.len(), + 2, + "IngressRoutes should be created after starting" + ); + + test.teardown().await; + } + #[tokio::test] #[ignore] async fn functional_test_app_service_podmonitor() { From d4a49fd1e18fa1582cfc546daf40ea89a46c7ee5 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Thu, 12 Dec 2024 13:35:02 -0500 Subject: [PATCH 5/5] Add list_params parameter to list_resources Signed-off-by: Ian Stanton --- tembo-operator/tests/integration_tests.rs | 67 +++++++++++++---------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/tembo-operator/tests/integration_tests.rs b/tembo-operator/tests/integration_tests.rs index eedd88f13..b429eed05 100644 --- a/tembo-operator/tests/integration_tests.rs +++ b/tembo-operator/tests/integration_tests.rs @@ -697,6 +697,7 @@ mod test { client: Client, cdb_name: &str, namespace: &str, + list_params: &ListParams, num_expected: usize, ) -> Result, errors::OperatorError> where @@ -709,12 +710,11 @@ mod test { R::DynamicType: Default, { let api: Api = Api::namespaced(client, namespace); - let lp = ListParams::default(); let retry = 15; let mut passed_retry = false; let mut resource_list: Vec = Vec::new(); for _ in 0..retry { - let resources = api.list(&lp).await?; + let resources = api.list(&list_params).await?; if resources.items.len() == num_expected { resource_list.extend(resources.items); passed_retry = true; @@ -3916,16 +3916,20 @@ mod test { let _coredb_resource = coredbs.patch(cdb_name, ¶ms, &patch).await.unwrap(); // assert we created three Deployments, with the names we provided + let default_params = ListParams::default(); let deployment_items: Vec = - list_resources(client.clone(), cdb_name, &namespace, 3) + list_resources(client.clone(), cdb_name, &namespace, &default_params, 3) .await .unwrap(); // three AppService deployments. the postgres exporter is disabled assert!(deployment_items.len() == 3); - let service_items: Vec = list_resources(client.clone(), cdb_name, &namespace, 2) - .await - .unwrap(); + let cdb_params = + ListParams::default().labels(format!("coredb.io/name={}", cdb_name).as_str()); + let service_items: Vec = + list_resources(client.clone(), cdb_name, &namespace, &cdb_params, 2) + .await + .unwrap(); // two AppService Services, because two of the AppServices expose ports assert!(service_items.len() == 2); @@ -4019,7 +4023,7 @@ mod test { assert!(found); let ingresses: Result, errors::OperatorError> = - list_resources(client.clone(), cdb_name, &namespace, 1).await; + list_resources(client.clone(), cdb_name, &namespace, &cdb_params, 1).await; let ingress = ingresses.unwrap(); assert_eq!(ingress.len(), 1); let ingress_route = ingress[0].clone(); @@ -4039,8 +4043,10 @@ mod test { // Check for IngressRouteTCP let ing_name = format!("{cdb_name}-ferretdb"); + let ing_params = + ListParams::default().labels(format!("coredb.io/name={}", ing_name).as_str()); let ingresses_tcp: Result, errors::OperatorError> = - list_resources(client.clone(), &ing_name, &namespace, 1).await; + list_resources(client.clone(), &ing_name, &namespace, &ing_params, 1).await; let ingress_tcp = ingresses_tcp.unwrap(); assert_eq!(ingress_tcp.len(), 1); let ingress_route_tcp = ingress_tcp[0].clone(); @@ -4146,7 +4152,7 @@ mod test { coredbs.patch(cdb_name, ¶ms, &patch).await.unwrap(); let deployment_items: Vec = - list_resources(client.clone(), cdb_name, &namespace, 1) + list_resources(client.clone(), cdb_name, &namespace, &default_params, 1) .await .unwrap(); assert!(deployment_items.len() == 1); @@ -4157,9 +4163,10 @@ mod test { ); // should still be just one Service - let service_items: Vec = list_resources(client.clone(), cdb_name, &namespace, 1) - .await - .unwrap(); + let service_items: Vec = + list_resources(client.clone(), cdb_name, &namespace, &cdb_params, 1) + .await + .unwrap(); // One appService Services assert!(service_items.len() == 1); @@ -4350,26 +4357,28 @@ CREATE EVENT TRIGGER pgrst_watch let patch = Patch::Apply(&coredb_json); coredbs.patch(cdb_name, ¶ms, &patch).await.unwrap(); let deployment_items: Vec = - list_resources(client.clone(), cdb_name, &namespace, 0) + list_resources(client.clone(), cdb_name, &namespace, &default_params, 0) .await .unwrap(); assert!(deployment_items.is_empty()); - let service_items: Vec = list_resources(client.clone(), cdb_name, &namespace, 0) - .await - .unwrap(); + let service_items: Vec = + list_resources(client.clone(), cdb_name, &namespace, &cdb_params, 0) + .await + .unwrap(); assert!(service_items.is_empty()); // should be no Services // ingress must be gone - let ingresses: Vec = list_resources(client.clone(), cdb_name, &namespace, 0) - .await - .unwrap(); + let ingresses: Vec = + list_resources(client.clone(), cdb_name, &namespace, &default_params, 0) + .await + .unwrap(); assert_eq!(ingresses.len(), 0); // Assert IngressRouteTCP is gone let ingresses_tcp: Vec = - list_resources(client.clone(), cdb_name, &namespace, 0) + list_resources(client.clone(), cdb_name, &namespace, &default_params, 0) .await .unwrap(); assert_eq!(ingresses_tcp.len(), 0); @@ -5810,6 +5819,7 @@ CREATE EVENT TRIGGER pgrst_watch let name = test.name.clone(); let pooler_name = format!("{}-pooler", name); let namespace = test.namespace.clone(); + let default_params = ListParams::default(); // Generate very simple CoreDB JSON definitions. The first will be for // initializing and starting the cluster, and the second for stopping @@ -5855,7 +5865,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert that IngressRouteTCPs are removed after hibernation let client = test.client.clone(); let ingresses_tcp: Vec = - list_resources(client.clone(), &name, &namespace, 0) + list_resources(client.clone(), &name, &namespace, &default_params, 0) .await .unwrap(); assert_eq!( @@ -5867,7 +5877,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert that IngressRoutes are removed after hibernation let client = test.client.clone(); let ingress_routes: Vec = - list_resources(client.clone(), &name, &namespace, 0) + list_resources(client.clone(), &name, &namespace, &default_params, 0) .await .unwrap(); assert_eq!( @@ -5887,7 +5897,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert there are 2 IngressRouteTCPs created after starting. 1 for postgres and 1 for the pooler let ingress_tcps: Vec = - list_resources(client.clone(), &name, &namespace, 2) + list_resources(client.clone(), &name, &namespace, &default_params, 2) .await .unwrap(); assert_eq!( @@ -5898,7 +5908,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert there is 1 IngressRoute created after starting. This is the IngressRoute for metrics let ingress_routes: Vec = - list_resources(client.clone(), &name, &namespace, 1) + list_resources(client.clone(), &name, &namespace, &default_params, 1) .await .unwrap(); assert_eq!( @@ -5918,6 +5928,7 @@ CREATE EVENT TRIGGER pgrst_watch let name = test.name.clone(); let pooler_name = format!("{}-pooler", name); let namespace = test.namespace.clone(); + let default_params = ListParams::default(); // Generate very simple CoreDB JSON definitions. The first will be for // initializing and starting the cluster with an app service, and the second for stopping @@ -6009,7 +6020,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert that IngressRouteTCPs are removed after hibernation let client = test.client.clone(); let ingresses_tcp: Vec = - list_resources(client.clone(), &name, &namespace, 0) + list_resources(client.clone(), &name, &namespace, &default_params, 0) .await .unwrap(); assert_eq!( @@ -6021,7 +6032,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert that IngressRoutes are removed after hibernation let client = test.client.clone(); let ingress_routes: Vec = - list_resources(client.clone(), &name, &namespace, 0) + list_resources(client.clone(), &name, &namespace, &default_params, 0) .await .unwrap(); assert_eq!( @@ -6045,7 +6056,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert there are 2 IngressRouteTCPs created after starting. 1 for postgres and 1 for the pooler let ingress_tcps: Vec = - list_resources(client.clone(), &name, &namespace, 2) + list_resources(client.clone(), &name, &namespace, &default_params, 2) .await .unwrap(); assert_eq!( @@ -6056,7 +6067,7 @@ CREATE EVENT TRIGGER pgrst_watch // Assert there are 2 IngressRoutes created after starting. 1 for metrics and 1 for the app service let ingress_routes: Vec = - list_resources(client.clone(), &name, &namespace, 2) + list_resources(client.clone(), &name, &namespace, &default_params, 2) .await .unwrap(); assert_eq!(