From 65a09ce32d2cdfae21797fa0d5b6380058ad2793 Mon Sep 17 00:00:00 2001 From: Egor Panfilov Date: Wed, 28 Mar 2018 21:19:15 +0300 Subject: [PATCH] Enable mutable config in Watcher New releases of oslo.config support a 'mutable' parameter to Opts. Configuration options are mutable if their oslo.config Opt's mutable=True is set. This mutable setting is respected when the oslo method mutate_config_files is called instead of reload_config_files. Icec3e664f3fe72614e373b2938e8dee53cf8bc5e allows services to tell oslo.service they want mutate_config_files to be called by specifying the 'restart_method=mutate' parameter, what this patch does. The default mutable configuration options (set by oslo.config Opts' mutable=True) are: - [DEFAULT]/pin_release_version - [DEFAULT]/debug - [DEFAULT]/log_config_append Concrete params, that made mutable in Watcher: * watcher_decision_engine.action_plan_expiry * watcher_decision_engine.check_periodic_interval * watcher_decision_engine.continuous_audit_interval * gnocchi_client.query_max_retries * gnocchi_client.query_timeout * DEFAULT.periodic_interval Change-Id: If28f2de094d99471a3ab756c947e29ae3d8a28a2 Implements: bp mutable-config --- watcher/common/service.py | 2 +- watcher/conf/decision_engine.py | 3 +++ watcher/conf/gnocchi_client.py | 2 ++ watcher/conf/service.py | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/watcher/common/service.py b/watcher/common/service.py index f2778c639..3528a47d5 100644 --- a/watcher/common/service.py +++ b/watcher/common/service.py @@ -289,7 +289,7 @@ class Service(service.ServiceBase): return api_manager_version -def launch(conf, service_, workers=1, restart_method='reload'): +def launch(conf, service_, workers=1, restart_method='mutate'): return service.launch(conf, service_, workers, restart_method) diff --git a/watcher/conf/decision_engine.py b/watcher/conf/decision_engine.py index f2ceb3a38..d284e1c48 100644 --- a/watcher/conf/decision_engine.py +++ b/watcher/conf/decision_engine.py @@ -44,18 +44,21 @@ WATCHER_DECISION_ENGINE_OPTS = [ 'execute strategies'), cfg.IntOpt('action_plan_expiry', default=24, + mutable=True, help='An expiry timespan(hours). Watcher invalidates any ' 'action plan for which its creation time ' '-whose number of hours has been offset by this value-' ' is older that the current time.'), cfg.IntOpt('check_periodic_interval', default=30 * 60, + mutable=True, help='Interval (in seconds) for checking action plan expiry.') ] WATCHER_CONTINUOUS_OPTS = [ cfg.IntOpt('continuous_audit_interval', default=10, + mutable=True, help='Interval (in seconds) for checking newly created ' 'continuous audits.') ] diff --git a/watcher/conf/gnocchi_client.py b/watcher/conf/gnocchi_client.py index d4b438c57..885aaf1d9 100644 --- a/watcher/conf/gnocchi_client.py +++ b/watcher/conf/gnocchi_client.py @@ -32,9 +32,11 @@ GNOCCHI_CLIENT_OPTS = [ 'The default is public.'), cfg.IntOpt('query_max_retries', default=10, + mutable=True, help='How many times Watcher is trying to query again'), cfg.IntOpt('query_timeout', default=1, + mutable=True, help='How many seconds Watcher should wait to do query again')] diff --git a/watcher/conf/service.py b/watcher/conf/service.py index 0f18d3a60..e0b24c4be 100644 --- a/watcher/conf/service.py +++ b/watcher/conf/service.py @@ -25,6 +25,7 @@ from watcher._i18n import _ SERVICE_OPTS = [ cfg.IntOpt('periodic_interval', default=60, + mutable=True, help=_('Seconds between running periodic tasks.')), cfg.HostAddressOpt('host', default=socket.gethostname(),