diff --git a/e2e/tests/test_e2e.py b/e2e/tests/test_e2e.py index 2300ebfe3..1bf723f12 100644 --- a/e2e/tests/test_e2e.py +++ b/e2e/tests/test_e2e.py @@ -926,6 +926,33 @@ class EndToEndTestCase(unittest.TestCase): self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync") self.eventuallyTrue(lambda: k8s.check_statefulset_annotations(cluster_label, annotations), "Annotations missing") + @timeout_decorator.timeout(TEST_TIMEOUT_SEC) + @unittest.skip("Skipping this test until fixed") + def test_zaa_test_major_version_upgrade(self): + k8s = self.k8s + result = k8s.create_with_kubectl("manifests/minimal-postgres-manifest-12.yaml") + self.eventuallyEqual(lambda: k8s.count_running_pods(labels="application=spilo,cluster-name=acid-upgrade-test"), 2, "No 2 pods running") + self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync") + + pg_patch_version = { + "spec": { + "postgres": { + "version": "13" + } + } + } + k8s.api.custom_objects_api.patch_namespaced_custom_object( + "acid.zalan.do", "v1", "default", "postgresqls", "acid-upgrade-test", pg_patch_version) + + self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync") + + def check_version_13(): + p = k8s.get_patroni_state("acid-upgrade-test-0") + version = p["server_version"][0:2] + return version + + self.evantuallyEqual(check_version_13, "13", "Version was not upgrade to 13") + @timeout_decorator.timeout(TEST_TIMEOUT_SEC) @unittest.skip("Skipping this test until fixed") def test_zzz_taint_based_eviction(self): diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index c35344b4d..8bb9b715b 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -74,6 +74,7 @@ data: # logical_backup_s3_secret_access_key: "" logical_backup_s3_sse: "AES256" logical_backup_schedule: "30 00 * * *" + major_version_upgrade_mode: "manual" master_dns_name_format: "{cluster}.{team}.{hostedzone}" # master_pod_move_timeout: 20m # max_instances: "-1" diff --git a/manifests/minimal-postgres-manifest-12.yaml b/manifests/minimal-postgres-manifest-12.yaml new file mode 100644 index 000000000..3f89b765d --- /dev/null +++ b/manifests/minimal-postgres-manifest-12.yaml @@ -0,0 +1,21 @@ +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: acid-upgrade-test + namespace: default +spec: + teamId: "acid" + volume: + size: 1Gi + numberOfInstances: 2 + users: + zalando: # database owner + - superuser + - createdb + foo_user: [] # role for application foo + databases: + foo: zalando # dbname: owner + preparedDatabases: + bar: {} + postgresql: + version: "12" diff --git a/pkg/cluster/majorversionupgrade.go b/pkg/cluster/majorversionupgrade.go index fe33b4a99..c1c49678e 100644 --- a/pkg/cluster/majorversionupgrade.go +++ b/pkg/cluster/majorversionupgrade.go @@ -9,12 +9,12 @@ import ( // VersionMap Map of version numbers var VersionMap = map[string]int{ - "9.5": 9500, - "9.6": 9600, - "10": 10000, - "11": 11000, - "12": 12000, - "13": 13000, + "9.5": 95000, + "9.6": 96000, + "10": 100000, + "11": 110000, + "12": 120000, + "13": 130000, } // IsBiggerPostgresVersion Compare two Postgres version numbers @@ -69,10 +69,10 @@ func (c *Cluster) majorVersionUpgrade() error { numberOfPods := len(pods) if allRunning && masterPod != nil { desiredVersion := c.GetDesiredMajorVersionAsInt() - c.logger.Infof("Cluster healthy with version: %d desired: %d", c.currentMajorVersion, desiredVersion) + c.logger.Infof("cluster healthy with version: %d desired: %d", c.currentMajorVersion, desiredVersion) if c.currentMajorVersion < desiredVersion { podName := &spec.NamespacedName{Namespace: masterPod.Namespace, Name: masterPod.Name} - c.logger.Infof("Triggering major version upgrade on pod %s", masterPod.Name) + c.logger.Infof("triggering major version upgrade on pod %s", masterPod.Name) c.ExecCommand(podName, fmt.Sprintf("python3 /scripts/inplace_upgrade.py %d", numberOfPods)) } }