diff --git a/patroni/api.py b/patroni/api.py index fb9fae99..c142c3b3 100644 --- a/patroni/api.py +++ b/patroni/api.py @@ -212,7 +212,7 @@ class RestApiHandler(BaseHTTPRequestHandler): data = "PostgreSQL role should be either master or replica" break elif k == 'postgres_version': - if not re.match(r'([1-9][0-9]?\.){2}[1-9][0-9]?$', request[k]): + if not re.match(r'[1-9][0-9]?(\.(0|([1-9][0-9]?))){2}$', request[k]): status_code = 400 data = "PostgreSQL version should be in the first.major.minor format" break diff --git a/tests/test_ha.py b/tests/test_ha.py index bb6a0155..cd0cd4ae 100644 --- a/tests/test_ha.py +++ b/tests/test_ha.py @@ -430,7 +430,7 @@ class TestHa(unittest.TestCase): self.p._role = 'replica' self.p.server_version = 90500 self.p._pending_restart = True - self.assertFalse(self.ha.restart_matches("master", "9.5.2", True)) + self.assertFalse(self.ha.restart_matches("master", "9.5.0", True)) self.assertFalse(self.ha.restart_matches("replica", "9.4.3", True)) self.p._pending_restart = False self.assertFalse(self.ha.restart_matches("replica", "9.5.2", True))