Improve workflow when PGDATA is not empty during bootstrap (#1217)

Recently it has happened two times when people tried to deploy the new cluster but postgres data directory wasn't empty and also wasn't valid. In this case Patroni was still creating initialize key in DCS and trying to start the postgres up.
Now it will complain about non-empty invalid postgres data directory and exit.

Close https://github.com/zalando/patroni/issues/1216
This commit is contained in:
Alexander Kukushkin
2019-10-25 14:09:44 +02:00
committed by GitHub
parent 0947ac1e43
commit 828585079f
5 changed files with 24 additions and 15 deletions
+2
View File
@@ -101,6 +101,7 @@ class TestPostgresql(BaseTestPostgresql):
@patch.object(Postgresql, 'wait_for_startup')
@patch.object(Postgresql, 'wait_for_port_open')
@patch.object(Postgresql, 'is_running')
@patch.object(Postgresql, 'controldata', Mock())
def test_start(self, mock_is_running, mock_wait_for_port_open, mock_wait_for_startup, mock_popen):
mock_is_running.return_value = MockPostmaster()
mock_wait_for_port_open.return_value = True
@@ -362,6 +363,7 @@ class TestPostgresql(BaseTestPostgresql):
@patch('os.listdir', Mock(return_value=['recovery.conf']))
@patch('os.path.exists', Mock(return_value=True))
@patch.object(Postgresql, 'controldata', Mock())
def test_get_postgres_role_from_data_directory(self):
self.assertEqual(self.p.get_postgres_role_from_data_directory(), 'replica')