From ea1a62e73d9e4d8f20cbd2ae4748a26ab5561856 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Mon, 14 Mar 2022 15:56:05 +0100 Subject: [PATCH] stretch pooler e2e test --- e2e/tests/test_e2e.py | 13 +++++++++++-- pkg/cluster/connection_pooler.go | 12 ++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/e2e/tests/test_e2e.py b/e2e/tests/test_e2e.py index 09b2c9c60..a425354a5 100644 --- a/e2e/tests/test_e2e.py +++ b/e2e/tests/test_e2e.py @@ -479,8 +479,6 @@ class EndToEndTestCase(unittest.TestCase): 'spec': { 'enableConnectionPooler': True, 'enableReplicaConnectionPooler': True, - 'enableMasterPoolerLoadBalancer': True, - 'enableReplicaPoolerLoadBalancer': True, } }) self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync") @@ -490,6 +488,17 @@ class EndToEndTestCase(unittest.TestCase): self.eventuallyEqual(lambda: k8s.count_running_pods(replica_pooler_label), 2, "No pooler replica pods found") self.eventuallyEqual(lambda: k8s.count_services_with_label(pooler_label), 2, "No pooler service found") self.eventuallyEqual(lambda: k8s.count_secrets_with_label(pooler_label), 1, "Pooler secret not created") + + k8s.api.custom_objects_api.patch_namespaced_custom_object( + 'acid.zalan.do', 'v1', 'default', + 'postgresqls', 'acid-minimal-cluster', + { + 'spec': { + 'enableMasterPoolerLoadBalancer': True, + 'enableReplicaPoolerLoadBalancer': True, + } + }) + self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync") self.eventuallyEqual(lambda: k8s.get_service_type(master_pooler_label+","+pooler_label), 'LoadBalancer', "Expected LoadBalancer service type for master pooler pod, found {}") diff --git a/pkg/cluster/connection_pooler.go b/pkg/cluster/connection_pooler.go index b9e27f1eb..5639b0283 100644 --- a/pkg/cluster/connection_pooler.go +++ b/pkg/cluster/connection_pooler.go @@ -818,7 +818,7 @@ func (c *Cluster) syncConnectionPoolerWorker(oldSpec, newSpec *acidv1.Postgresql var ( deployment *appsv1.Deployment newDeployment *appsv1.Deployment - svc *v1.Service + service *v1.Service newService *v1.Service err error ) @@ -907,13 +907,13 @@ func (c *Cluster) syncConnectionPoolerWorker(oldSpec, newSpec *acidv1.Postgresql c.ConnectionPooler[role].Deployment = deployment } - if svc, err = c.KubeClient.Services(c.Namespace).Get(context.TODO(), c.connectionPoolerName(role), metav1.GetOptions{}); err == nil { - c.ConnectionPooler[role].Service = svc + if service, err = c.KubeClient.Services(c.Namespace).Get(context.TODO(), c.connectionPoolerName(role), metav1.GetOptions{}); err == nil { + c.ConnectionPooler[role].Service = service desiredSvc := c.generateConnectionPoolerService(c.ConnectionPooler[role]) - if match, reason := k8sutil.SameService(svc, desiredSvc); !match { + if match, reason := k8sutil.SameService(service, desiredSvc); !match { syncReason = append(syncReason, reason) - c.logServiceChanges(role, svc, desiredSvc, false, reason) - newService, err = c.updateService(role, svc, desiredSvc) + c.logServiceChanges(role, service, desiredSvc, false, reason) + newService, err = c.updateService(role, service, desiredSvc) if err != nil { return syncReason, fmt.Errorf("could not update %s service to match desired state: %v", role, err) }