Log config change or not (#731)

This adds INFO log messages that clearly state if configuration values were seen as changed by Patroni after SIGHUP/reload and warrant reloading (or if nothing was changed an no reloading is necessary).

This ended up being a lot simpler than I had imagined once I found postgresql.py:reload_config().

I add a log line in config.py:reload_local_configuration() since that function will short-circuit the process early if the local config wasn't changed. But the final determination of whether or not values have changed and need reloading is in postgresql.py:reload_config().
This commit is contained in:
Don Seiler
2018-08-03 17:00:57 +02:00
committed by Alexander Kukushkin
parent 0c1ae6fbeb
commit 502094ee79
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -158,6 +158,8 @@ class Config(object):
self._local_configuration = configuration
self.__effective_configuration = new_configuration
return True
else:
logger.info('No configuration items changed, nothing to reload.')
except Exception:
logger.exception('Exception when reloading local configuration from %s', self.config_file)
if dry_run:
+7
View File
@@ -337,10 +337,12 @@ class Postgresql(object):
if new_value is None or not compare_values(r[3], unit, r[1], new_value):
if r[4] == 'postmaster':
pending_restart = True
logger.info('Changed %s from %s to %s (restart required)', r[0], r[1], new_value)
if config.get('use_unix_socket') and r[0] == 'unix_socket_directories'\
or r[0] in ('listen_addresses', 'port'):
local_connection_address_changed = True
else:
logger.info('Changed %s from %s to %s', r[0], r[1], new_value)
conf_changed = True
for param in changes:
if param in server_parameters:
@@ -351,11 +353,13 @@ class Postgresql(object):
if not conf_changed:
for p, v in server_parameters.items():
if '.' in p and (p not in self._server_parameters or str(v) != str(self._server_parameters[p])):
logger.info('Changed %s from %s to %s', p, self._server_parameters.get(p), v)
conf_changed = True
break
if not conf_changed:
for p, v in self._server_parameters.items():
if '.' in p and (p not in server_parameters or str(v) != str(server_parameters[p])):
logger.info('Changed %s from %s to %s', p, v, server_parameters.get(p))
conf_changed = True
break
@@ -377,7 +381,10 @@ class Postgresql(object):
self._replace_pg_hba()
if conf_changed or hba_changed:
logger.info('PostgreSQL configuration items changed, reloading configuration.')
self.reload()
elif not pending_restart:
logger.info('No PostgreSQL configuration items changed, nothing to reload.')
self._is_leader_retry.deadline = self.retry.deadline = config['retry_timeout']/2.0