← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~ack/maas:revert-pg-14-bump into maas:master

 

Alberto Donato has proposed merging ~ack/maas:revert-pg-14-bump into maas:master.

Commit message:
Revert "bump minimum required PostgreSQL version to 14"

This reverts commit 0b26d1f070ea403cdf7d012890ae10828155d1e3.



Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~ack/maas/+git/maas/+merge/437504
-- 
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maasserver/deprecations.py b/src/maasserver/deprecations.py
index 739df44..f31d5f2 100644
--- a/src/maasserver/deprecations.py
+++ b/src/maasserver/deprecations.py
@@ -1,6 +1,7 @@
 # Copyright 2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from maasserver.utils.orm import postgresql_major_version
 from provisioningserver.logger import LegacyLogger
 
 DEPRECATION_URL = "https://maas.io/deprecations/{id}";
@@ -26,13 +27,24 @@ class Deprecation:
         )
 
 
-# all known deprecation notices, mapping symbolic name to the deprecation info
-DEPRECATIONS: dict[str, Deprecation] = {}
+# all known deprecation notices
+DEPRECATIONS = {
+    "POSTGRES_OLDER_THAN_14": Deprecation(
+        id="MD3",
+        since="3.3",
+        description="The PostgreSQL version in use is older than 14.",
+        link_text="How to upgrade the PostgreSQL server",
+    )
+}
 
 
-def get_deprecations() -> list[Deprecation]:
+def get_deprecations():
     """Return a list of currently active deprecation notices."""
-    return []
+
+    deprecations = []
+    if postgresql_major_version() < 14:
+        deprecations.append(DEPRECATIONS["POSTGRES_OLDER_THAN_14"])
+    return deprecations
 
 
 def log_deprecations(logger=None):
diff --git a/src/maasserver/plugin.py b/src/maasserver/plugin.py
index b1349be..e38437c 100644
--- a/src/maasserver/plugin.py
+++ b/src/maasserver/plugin.py
@@ -29,7 +29,7 @@ from provisioningserver.utils.debug import (
 
 log = LegacyLogger()
 
-PGSQL_MIN_VERSION = 14
+PGSQL_MIN_VERSION = 12
 
 
 class UnsupportedDBException(Exception):
diff --git a/src/maasserver/tests/test_deprecations.py b/src/maasserver/tests/test_deprecations.py
index 45adf38..7794f88 100644
--- a/src/maasserver/tests/test_deprecations.py
+++ b/src/maasserver/tests/test_deprecations.py
@@ -1,6 +1,7 @@
 from maasserver import deprecations
 from maasserver.deprecations import (
     Deprecation,
+    DEPRECATIONS,
     get_deprecations,
     log_deprecations,
     sync_deprecation_notifications,
@@ -15,6 +16,12 @@ class TestGetDeprecations(MAASServerTestCase):
     def test_empty(self):
         self.assertEqual(get_deprecations(), [])
 
+    def test_old_postgres_version(self):
+        self.patch(deprecations, "postgresql_major_version").return_value = 12
+        self.assertEqual(
+            get_deprecations(), [DEPRECATIONS["POSTGRES_OLDER_THAN_14"]]
+        )
+
 
 class TestLogDeprecations(MAASTestCase):
     def test_log_deprecations(self):
diff --git a/src/maasserver/tests/test_start_up.py b/src/maasserver/tests/test_start_up.py
index 67c2406..681e9d1 100644
--- a/src/maasserver/tests/test_start_up.py
+++ b/src/maasserver/tests/test_start_up.py
@@ -264,14 +264,7 @@ class TestInnerStartUp(MAASServerTestCase):
         )
 
     def test_logs_deprecation_notifications(self):
-        self.patch(deprecations, "get_deprecations").return_value = [
-            deprecations.Deprecation(
-                id="MD100",
-                since="3.3",
-                description="deprecation",
-                link_text="deprecation",
-            )
-        ]
+        self.patch(deprecations, "postgresql_major_version").return_value = 12
         mock_log = self.patch(start_up, "log")
         with post_commit_hooks:
             start_up.inner_start_up(master=True)

Follow ups