ProcessLauncher: reload config file in parent process on SIGHUP
Currently, when a parent process receives SIGHUP it just sends SIGHUP to its children. While children reload their config files and call reset on their services, parent continues to run with old config. Add reloading of config file and calling reset for service on receiving SIGHUP. Closes-Bug: #1433142 Change-Id: I132865fc5c3a12baf02f2991fc82701adfc7ed67
This commit is contained in:
@@ -391,8 +391,14 @@ class ProcessLauncher(object):
|
||||
if not _is_sighup_and_daemon(self.sigcaught):
|
||||
break
|
||||
|
||||
cfg.CONF.reload_config_files()
|
||||
for service in set(
|
||||
[wrap.service for wrap in self.children.values()]):
|
||||
service.reset()
|
||||
|
||||
for pid in self.children:
|
||||
os.kill(pid, signal.SIGHUP)
|
||||
|
||||
self.running = True
|
||||
self.sigcaught = None
|
||||
except eventlet.greenlet.GreenletExit:
|
||||
|
||||
@@ -412,6 +412,37 @@ class ProcessLauncherTest(test_base.BaseTestCase):
|
||||
for m in service.ProcessLauncher._signal_handlers_set:
|
||||
m.assert_called_once_with()
|
||||
|
||||
@mock.patch("os.kill")
|
||||
@mock.patch("openstack.common.service.ProcessLauncher.stop")
|
||||
@mock.patch("openstack.common.service.ProcessLauncher._respawn_children")
|
||||
@mock.patch("openstack.common.service.ProcessLauncher.handle_signal")
|
||||
@mock.patch("oslo_config.cfg.CONF.log_opt_values")
|
||||
@mock.patch("openstack.common.systemd.notify_once")
|
||||
@mock.patch("oslo_config.cfg.CONF.reload_config_files")
|
||||
@mock.patch("openstack.common.service._is_sighup_and_daemon")
|
||||
def test_parent_process_reload_config(self,
|
||||
is_sighup_and_daemon_mock,
|
||||
reload_config_files_mock,
|
||||
notify_once_mock,
|
||||
log_opt_values_mock,
|
||||
handle_signal_mock,
|
||||
respawn_children_mock,
|
||||
stop_mock,
|
||||
kill_mock):
|
||||
is_sighup_and_daemon_mock.return_value = True
|
||||
respawn_children_mock.side_effect = [None,
|
||||
eventlet.greenlet.GreenletExit()]
|
||||
launcher = service.ProcessLauncher()
|
||||
launcher.sigcaught = 1
|
||||
launcher.children = {}
|
||||
|
||||
wrap_mock = mock.Mock()
|
||||
launcher.children[222] = wrap_mock
|
||||
launcher.wait()
|
||||
|
||||
reload_config_files_mock.assert_called_once_with()
|
||||
wrap_mock.service.reset.assert_called_once_with()
|
||||
|
||||
|
||||
class GracefulShutdownTestService(service.Service):
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user