From 4299b38883c7c711ff3e349f5b134b6c9a272caf Mon Sep 17 00:00:00 2001 From: bhagyashris Date: Mon, 9 Apr 2018 18:46:50 +0530 Subject: [PATCH] Enable mutable config in Masakari New releases of oslo.config support a 'mutable' parameter to Opts. This is only respected when the new method mutate_config_files is called instead of reload_config_files. Masakari delegates making this call to oslo.service, so how do we switch? Icec3e664f3fe72614e373b2938e8dee53cf8bc5e allows services to tell oslo.service they want mutate_config_files to be called by passing a parameter, which this patch does. This allows Masakari to benefit from I1e7a69de169cc85f4c09954b2f46ce2da7106d90, where the 'debug' option (owned by oslo.log) is made mutable. We should be able to turn debug logging on and off by changing the config and sending SIGHUP. Also in this patch configuration parameter 'retry_notification_new_status_interval' is marked as mutable. Part of bp:mutable-config Change-Id: Icf4438b98420eb0e9d35a19cf88831f359c74fe5 --- masakari/conf/engine.py | 1 + masakari/service.py | 5 +++-- masakari/tests/unit/test_service.py | 6 ++++-- .../notes/bp-mutable-config-57efdd467c01aa7b.yaml | 8 ++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bp-mutable-config-57efdd467c01aa7b.yaml diff --git a/masakari/conf/engine.py b/masakari/conf/engine.py index 118e3ae0..cd19227f 100644 --- a/masakari/conf/engine.py +++ b/masakari/conf/engine.py @@ -90,6 +90,7 @@ notification_opts = [ 'are in error or new state.'), cfg.IntOpt('retry_notification_new_status_interval', default=60, + mutable=True, help="Interval in seconds for identifying notifications which " "are in new state. If the notification is in new state " "till this config option value after it's " diff --git a/masakari/service.py b/masakari/service.py index 949a105f..df7eda94 100644 --- a/masakari/service.py +++ b/masakari/service.py @@ -271,7 +271,7 @@ class WSGIService(service.Service): def process_launcher(): - return service.ProcessLauncher(CONF) + return service.ProcessLauncher(CONF, restart_method='mutate') # NOTE: the global launcher is to maintain the existing @@ -285,7 +285,8 @@ def serve(server, workers=None): if _launcher: raise RuntimeError(_('serve() can only be called once')) - _launcher = service.launch(CONF, server, workers=workers) + _launcher = service.launch(CONF, server, workers=workers, + restart_method='mutate') def wait(): diff --git a/masakari/tests/unit/test_service.py b/masakari/tests/unit/test_service.py index 04609ee1..a7c9d52c 100644 --- a/masakari/tests/unit/test_service.py +++ b/masakari/tests/unit/test_service.py @@ -160,7 +160,8 @@ class TestLauncher(test.NoDBTestCase): service.serve(mock.sentinel.service) mock_launch.assert_called_once_with(mock.ANY, mock.sentinel.service, - workers=None) + workers=None, + restart_method='mutate') @mock.patch.object(_service, 'launch') def test_launch_app_with_workers(self, mock_launch): @@ -168,7 +169,8 @@ class TestLauncher(test.NoDBTestCase): service.serve(mock.sentinel.service, workers=mock.sentinel.workers) mock_launch.assert_called_once_with(mock.ANY, mock.sentinel.service, - workers=mock.sentinel.workers) + workers=mock.sentinel.workers, + restart_method='mutate') @mock.patch.object(_service, 'launch') def test_launch_app_more_than_once_raises(self, mock_launch): diff --git a/releasenotes/notes/bp-mutable-config-57efdd467c01aa7b.yaml b/releasenotes/notes/bp-mutable-config-57efdd467c01aa7b.yaml new file mode 100644 index 00000000..8bb86cc8 --- /dev/null +++ b/releasenotes/notes/bp-mutable-config-57efdd467c01aa7b.yaml @@ -0,0 +1,8 @@ +--- +features: + - | + Masakari has been enabled for mutable config. + Below option may be reloaded by sending SIGHUP to the correct process. + + 'retry_notification_new_status_interval' option will apply to process + unfinished notifications.