mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Move initialization of global_config to Patroni class (#3309)
we rely on it's value when creating instance of Postgresql class
This commit is contained in:
+4
-1
@@ -12,7 +12,7 @@ import time
|
||||
from argparse import Namespace
|
||||
from typing import Any, Dict, List, Optional, TYPE_CHECKING
|
||||
|
||||
from patroni import MIN_PSYCOPG2, MIN_PSYCOPG3, parse_version
|
||||
from patroni import global_config, MIN_PSYCOPG2, MIN_PSYCOPG3, parse_version
|
||||
from patroni.daemon import abstract_main, AbstractPatroniDaemon, get_base_arg_parser
|
||||
from patroni.tags import Tags
|
||||
|
||||
@@ -70,6 +70,9 @@ class Patroni(AbstractPatroniDaemon, Tags):
|
||||
self.watchdog = Watchdog(self.config)
|
||||
self.apply_dynamic_configuration(cluster)
|
||||
|
||||
# Initialize global config
|
||||
global_config.update(None, self.config.dynamic_configuration)
|
||||
|
||||
self.postgresql = Postgresql(self.config['postgresql'], self.dcs.mpp)
|
||||
self.api = RestApiServer(self, self.config['restapi'])
|
||||
self.ha = Ha(self)
|
||||
|
||||
@@ -263,9 +263,6 @@ class Ha(object):
|
||||
# used only in backoff after failing a pre_promote script
|
||||
self._released_leader_key_timestamp = 0
|
||||
|
||||
# Initialize global config
|
||||
global_config.update(None, self.patroni.config.dynamic_configuration)
|
||||
|
||||
def primary_stop_timeout(self) -> Union[int, None]:
|
||||
""":returns: "primary_stop_timeout" from the global configuration or `None` when not in synchronous mode."""
|
||||
ret = global_config.primary_stop_timeout
|
||||
|
||||
@@ -94,6 +94,8 @@ class Postgresql(object):
|
||||
self._connection = self.connection_pool.get('heartbeat')
|
||||
self.mpp_handler = mpp.get_handler_impl(self)
|
||||
self._bin_dir = config.get('bin_dir') or ''
|
||||
self._role_lock = Lock()
|
||||
self.set_role('uninitialized')
|
||||
self.config = ConfigHandler(self, config)
|
||||
self.config.check_directories()
|
||||
|
||||
@@ -118,7 +120,6 @@ class Postgresql(object):
|
||||
self._is_leader_retry = Retry(max_tries=1, deadline=config['retry_timeout'] / 2.0, max_delay=1,
|
||||
retry_exceptions=PostgresConnectionException)
|
||||
|
||||
self._role_lock = Lock()
|
||||
self.set_role(self.get_postgres_role_from_data_directory())
|
||||
self._state_entry_timestamp = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user