Add pending restart reason information (#2978)

Provide info about the PG parameters that caused "pending restart"
flag to be set. Both `patronictl list` and `/patroni` REST API endpoint
now show the parameters names and the diff as the "pending restart
reason".
This commit is contained in:
Polina Bungina
2024-02-14 08:54:20 +01:00
committed by GitHub
parent 7adfc0dbe7
commit bdd02324b4
12 changed files with 164 additions and 52 deletions
+5 -3
View File
@@ -4,10 +4,11 @@ import sys
from mock import Mock, PropertyMock, patch
from patroni.async_executor import CriticalTask
from patroni.collections import CaseInsensitiveDict
from patroni.postgresql import Postgresql
from patroni.postgresql.bootstrap import Bootstrap
from patroni.postgresql.cancellable import CancellableSubprocess
from patroni.postgresql.config import ConfigHandler
from patroni.postgresql.config import ConfigHandler, get_param_diff
from . import psycopg_connect, BaseTestPostgresql, mock_available_gucs
@@ -245,8 +246,9 @@ class TestBootstrap(BaseTestPostgresql):
self.assertTrue(task.result)
self.b.bootstrap(config)
with patch.object(Postgresql, 'pending_restart', PropertyMock(return_value=True)), \
patch.object(Postgresql, 'restart', Mock()) as mock_restart:
with patch.object(Postgresql, 'pending_restart_reason',
PropertyMock(CaseInsensitiveDict({'max_connections': get_param_diff('200', '100')}))), \
patch.object(Postgresql, 'restart', Mock()) as mock_restart:
self.b.post_bootstrap({}, task)
mock_restart.assert_called_once()