From ce522ffeeb19728476effee485a4d804e58b4f44 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Fri, 16 Jul 2021 14:54:04 +0200 Subject: [PATCH] enhance e2e test and improve log messages in sync --- e2e/tests/test_e2e.py | 15 +++++++++++---- pkg/cluster/sync.go | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/e2e/tests/test_e2e.py b/e2e/tests/test_e2e.py index e53156cfa..0970953a9 100644 --- a/e2e/tests/test_e2e.py +++ b/e2e/tests/test_e2e.py @@ -1431,13 +1431,14 @@ class EndToEndTestCase(unittest.TestCase): masterPod = k8s.get_cluster_leader_pod() labels = 'application=spilo,cluster-name=acid-minimal-cluster,spilo-role=master' creationTimestamp = masterPod.metadata.creation_timestamp + new_max_connections_value = "50" # adjust max_connection pg_patch_config = { "spec": { "postgresql": { "parameters": { - "max_connections": "50" + "max_connections": new_max_connections_value } }, "patroni": { @@ -1466,7 +1467,7 @@ class EndToEndTestCase(unittest.TestCase): desired_parameters = pg_patch_config["spec"]["postgresql"]["parameters"] effective_parameters = effective_config["postgresql"]["parameters"] self.assertEqual(desired_parameters["max_connections"], effective_parameters["max_connections"], - "max_connectoins not updated") + "max_connections not updated") self.assertTrue(effective_config["slots"] is not None, "physical replication slot not added") self.assertEqual(desired_patroni["ttl"], effective_config["ttl"], "ttl not updated") @@ -1479,8 +1480,14 @@ class EndToEndTestCase(unittest.TestCase): return True self.eventuallyTrue(compare_config, "Postgres config not applied") - pods = k8s.api.core_v1.list_namespaced_pod( - 'default', label_selector=labels).items + + setting_query = """ + SELECT setting + FROM pg_settings + WHERE name = 'max_connections'; + """ + self.eventuallyEqual(lambda: self.query_database(masterPod.metadata.name, "postgres", setting_query)[0], new_max_connections_value, + "New max_connections setting not applied", 10, 5) # make sure that pod wasn't recreated self.assertEqual(creationTimestamp, masterPod.metadata.creation_timestamp, diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 88bb066fe..91ae40e5b 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -273,7 +273,7 @@ func (c *Cluster) syncStatefulSet() error { pods, err := c.listPods() if err != nil { - c.logger.Infof("could not list pods of the statefulset: %v", err) + c.logger.Warnf("could not list pods of the statefulset: %v", err) } // NB: Be careful to consider the codepath that acts on podsRollingUpdateRequired before returning early. @@ -388,7 +388,7 @@ func (c *Cluster) syncStatefulSet() error { // since those parameters require PostgreSQL restart. pods, err = c.listPods() if err != nil { - c.logger.Infof("could not list pods of the statefulset: %v", err) + c.logger.Warnf("could not get list of pods to apply special PostgreSQL parameters only to be set via Patroni API: %v", err) } for i, pod := range pods { @@ -407,7 +407,7 @@ func (c *Cluster) syncStatefulSet() error { instanceRestartRequired, err = c.checkAndSetGlobalPostgreSQLConfiguration(&pod, config) if err != nil { - return fmt.Errorf("could not set cluster-wide PostgreSQL configuration options: %v", err) + return fmt.Errorf("could not set PostgreSQL configuration options for pod %s: %v", podName, err) } if instanceRestartRequired {