Tune health manager options

This patch massages the options related to periodic tasks. It is a
preparation for future improvement to the health manager. Note that the
options changes are all transparent to users, i.e. they still belong to
the [default] section.

Change-Id: I7317264ba2ac4aeeade8915a9cb4afedd50edc2a
This commit is contained in:
tengqm 2016-05-20 06:00:49 -04:00
parent e3b4762c7b
commit 3a2352808b
4 changed files with 43 additions and 38 deletions

View File

@ -1,15 +1,14 @@
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Routines for configuring Senlin
@ -23,21 +22,31 @@ from senlin.common.i18n import _
# DEFAULT, service
service_opts = [
cfg.IntOpt('periodic_interval',
default=60,
help=_('Seconds between running periodic tasks.')),
cfg.StrOpt('default_region_name',
help=_('Default region name used to get services endpoints.')),
cfg.IntOpt('max_response_size',
default=524288,
help=_('Maximum raw byte size of data from web response.')),
cfg.IntOpt('num_engine_workers',
default=1,
help=_('Number of senlin-engine processes to fork and run.'))]
help=_('Maximum raw byte size of data from web response.'))
]
cfg.CONF.register_opts(service_opts)
# DEFAULT, engine
engine_opts = [
cfg.IntOpt('periodic_interval',
default=60,
help=_('Seconds between running periodic tasks.')),
cfg.IntOpt('periodic_interval_max',
default=120,
help='Seconds between periodic tasks to be called'),
cfg.IntOpt('periodic_fuzzy_delay',
default=10,
help='Range of seconds to randomly delay when starting the'
' periodic task scheduler to reduce stampeding.'
' (Disable by setting to 0)'),
cfg.IntOpt('num_engine_workers',
default=1,
help=_('Number of senlin-engine processes to fork and run.')),
cfg.StrOpt('environment_dir',
default='/etc/senlin/environments',
help=_('The directory to search for environment files.')),
@ -73,7 +82,8 @@ engine_opts = [
cfg.BoolOpt('name_unique',
default=False,
help=_('Flag to indicate whether to enforce unique names for '
'Senlin objects belonging to the same project.'))]
'Senlin objects belonging to the same project.'))
]
cfg.CONF.register_opts(engine_opts)
# DEFAULT, cloud_backend
@ -82,7 +92,8 @@ rpc_opts = [
default=socket.gethostname(),
help=_('Name of the engine node. This can be an opaque '
'identifier. It is not necessarily a hostname, FQDN, '
'or IP address.'))]
'or IP address.'))
]
cfg.CONF.register_opts(rpc_opts)
# DEFAULT, cloud_backend
@ -110,13 +121,24 @@ authentication_opts = [
cfg.CONF.register_group(authentication_group)
cfg.CONF.register_opts(authentication_opts, group=authentication_group)
# Health Manager Group
healthmgr_group = cfg.OptGroup('health_manager')
healthmgr_opts = [
cfg.StrOpt('nova_control_exchange',
default='nova',
help="Exchange name for nova notifications"),
]
cfg.CONF.register_group(healthmgr_group)
cfg.CONF.register_opts(healthmgr_opts, group=healthmgr_group)
# Revision group
revision_group = cfg.OptGroup('revision')
revision_opts = [
cfg.StrOpt('senlin_api_revision', default='1.0',
help=_('Senlin API revision.')),
cfg.StrOpt('senlin_engine_revision', default='1.0',
help=_('Senlin engine revision.'))]
help=_('Senlin engine revision.'))
]
cfg.CONF.register_group(revision_group)
cfg.CONF.register_opts(revision_opts, group=revision_group)

View File

@ -30,16 +30,6 @@ from senlin.db import api as db_api
from senlin.rpc import client as rpc_client
health_mgr_opts = [
cfg.IntOpt('periodic_interval_max',
default=60,
help='Seconds between periodic tasks to be called'),
]
CONF = cfg.CONF
CONF.register_opts(health_mgr_opts)
class HealthManager(service.Service):
def __init__(self, engine_service, topic, version):
@ -50,7 +40,6 @@ class HealthManager(service.Service):
self.topic = topic
self.version = version
self.ctx = context.get_admin_context()
self.periodic_interval_max = CONF.periodic_interval_max
self.rpc_client = rpc_client.EngineClient()
self.rt = {
'registries': [],
@ -77,7 +66,7 @@ class HealthManager(service.Service):
for registry in self.registries:
if registry.get('check_type') == 'NODE_STATUS_POLLING':
interval = min(registry.get('interval'),
self.periodic_interval_max)
cfg.CONF.periodic_interval_max)
timer = self.TG.add_timer(interval, self._periodic_check, None,
registry.get('cluster_id'))
registry['timer'] = timer
@ -135,7 +124,7 @@ class HealthManager(service.Service):
timer = None
if check_type == 'NODE_STATUS_POLLING':
real_interval = min(interval, self.periodic_interval_max)
real_interval = min(interval, cfg.CONF.periodic_interval_max)
timer = self.TG.add_timer(real_interval, self._periodic_check,
None, cluster_id)
@ -214,7 +203,3 @@ def unregister(cluster_id, engine_id=None):
return notify(engine_id,
'unregister_cluster',
cluster_id=cluster_id)
def list_opts():
yield None, health_mgr_opts

View File

@ -44,7 +44,6 @@ class TestHealthManager(base.SenlinTestCase):
self.assertIsNotNone(self.hm.rpc_client)
self.assertEqual(consts.ENGINE_HEALTH_MGR_TOPIC, self.hm.topic)
self.assertEqual(consts.RPC_API_VERSION, self.hm.version)
self.assertEqual(60, self.hm.periodic_interval_max)
self.assertEqual(0, len(self.hm.rt['registries']))
@mock.patch.object(db_api, 'registry_claim')

View File

@ -3,7 +3,6 @@ output_file = etc/senlin/senlin.conf.sample
wrap_width = 119
namespace = senlin.common.config
namespace = senlin.api.common.wsgi
namespace = senlin.engine.health_manager
namespace = keystonemiddleware.auth_token
namespace = oslo.db
namespace = oslo.log