From a11afbe704e039a1fa09bf68dc03233dd2c83f54 Mon Sep 17 00:00:00 2001 From: zhurong Date: Thu, 22 Mar 2018 19:56:44 +0800 Subject: [PATCH] Enable mutable config in Murano 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. Heat 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 Murano 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. Change-Id: Ia7e405392fe67eb9c4abf2408db0fa25c5546958 Story: 2001545 --- murano/cmd/api.py | 4 +++- murano/cmd/engine.py | 5 +++-- murano/tests/unit/cmd/test_api_workers.py | 9 ++++++--- murano/tests/unit/cmd/test_engine_workers.py | 9 ++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/murano/cmd/api.py b/murano/cmd/api.py index 2ad1d234c..d9802aef4 100644 --- a/murano/cmd/api.py +++ b/murano/cmd/api.py @@ -63,7 +63,9 @@ def main(): workers = CONF.murano.api_workers if not workers: workers = processutils.get_worker_count() - launcher = service.launch(CONF, server.ApiService(), workers=workers) + launcher = service.launch( + CONF, server.ApiService(), + workers=workers, restart_method='mutate') app = app_loader.load_paste_app('murano') port, host = (CONF.bind_port, CONF.bind_host) diff --git a/murano/cmd/engine.py b/murano/cmd/engine.py index c524b5111..9318064f9 100644 --- a/murano/cmd/engine.py +++ b/murano/cmd/engine.py @@ -53,8 +53,9 @@ def main(): workers = CONF.engine.engine_workers if not workers: workers = processutils.get_worker_count() - launcher = service.launch(CONF, - engine.EngineService(), workers=workers) + launcher = service.launch( + CONF, engine.EngineService(), + workers=workers, restart_method='mutate') launcher.wait() except RuntimeError as e: sys.stderr.write("ERROR: %s\n" % e) diff --git a/murano/tests/unit/cmd/test_api_workers.py b/murano/tests/unit/cmd/test_api_workers.py index 20fabc504..690d771df 100644 --- a/murano/tests/unit/cmd/test_api_workers.py +++ b/murano/tests/unit/cmd/test_api_workers.py @@ -39,7 +39,8 @@ class TestAPIWorkers(base.MuranoTestCase): load_paste_app, set_middleware_defaults): api.main() launch.assert_called_once_with(mock.ANY, mock.ANY, - workers=processutils.get_worker_count()) + workers=processutils.get_worker_count(), + restart_method='mutate') @mock.patch.object(config, 'parse_args') @mock.patch.object(logging, 'setup') @@ -51,7 +52,8 @@ class TestAPIWorkers(base.MuranoTestCase): load_paste_app, set_middleware_defaults): self.override_config("api_workers", 8, "murano") api.main() - launch.assert_called_once_with(mock.ANY, mock.ANY, workers=8) + launch.assert_called_once_with(mock.ANY, mock.ANY, workers=8, + restart_method='mutate') @mock.patch.object(config, 'parse_args') @mock.patch.object(logging, 'setup') @@ -64,4 +66,5 @@ class TestAPIWorkers(base.MuranoTestCase): self.override_config("api_workers", 0, "murano") api.main() launch.assert_called_once_with(mock.ANY, mock.ANY, - workers=processutils.get_worker_count()) + workers=processutils.get_worker_count(), + restart_method='mutate') diff --git a/murano/tests/unit/cmd/test_engine_workers.py b/murano/tests/unit/cmd/test_engine_workers.py index 2b3f95f34..6ef71582a 100644 --- a/murano/tests/unit/cmd/test_engine_workers.py +++ b/murano/tests/unit/cmd/test_engine_workers.py @@ -30,7 +30,8 @@ class TestEngineWorkers(base.MuranoTestCase): def test_workers_default(self, launch, setup, parse_args): engine.main() launch.assert_called_once_with(mock.ANY, mock.ANY, - workers=processutils.get_worker_count()) + workers=processutils.get_worker_count(), + restart_method='mutate') @mock.patch.object(config, 'parse_args') @mock.patch.object(logging, 'setup') @@ -38,7 +39,8 @@ class TestEngineWorkers(base.MuranoTestCase): def test_workers_good_setting(self, launch, setup, parse_args): self.override_config("engine_workers", 8, "engine") engine.main() - launch.assert_called_once_with(mock.ANY, mock.ANY, workers=8) + launch.assert_called_once_with(mock.ANY, mock.ANY, workers=8, + restart_method='mutate') @mock.patch.object(config, 'parse_args') @mock.patch.object(logging, 'setup') @@ -47,4 +49,5 @@ class TestEngineWorkers(base.MuranoTestCase): self.override_config("engine_workers", 0, "engine") engine.main() launch.assert_called_once_with(mock.ANY, mock.ANY, - workers=processutils.get_worker_count()) + workers=processutils.get_worker_count(), + restart_method='mutate')