Add send_cluster_metrics configuration parameter

Added configuration parameter, send_cluster_metrics, to magnum.conf
with default value of True. If set to True, periodic tasks will pull
COE data and send to ceilometer. This parameter can be set to False to
disable periodic collection of data to avoid unnecessary load from the
cluster.

Closes-Bug: #1668330
Related-Bug: #1746510

Change-Id: I9945293e7b2b52731f6e220d0925c1f6ad097caa
This commit is contained in:
Kirsten G 2017-12-19 07:57:55 -08:00
parent a43ab8f125
commit cf84683940
4 changed files with 37 additions and 1 deletions

View File

@ -225,6 +225,7 @@ function create_magnum_conf {
# default in magnum.conf
default_volume_type=$(iniget /etc/cinder/cinder.conf DEFAULT default_volume_type)
iniset $MAGNUM_CONF cinder default_docker_volume_type $default_volume_type
iniset $MAGNUM_CONF drivers send_cluster_metrics False
}
function create_api_paste_conf {

View File

@ -29,7 +29,11 @@ drivers_opts = [
cfg.StrOpt('openstack_ca_file',
default="",
help='Path to the OpenStack CA-bundle file to pass and '
'install in all cluster nodes.')
'install in all cluster nodes.'),
cfg.BoolOpt('send_cluster_metrics',
default=True,
help='Allow periodic tasks to pull COE data and send to '
'ceilometer.')
]

View File

@ -141,6 +141,10 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
@periodic_task.periodic_task(run_immediately=True)
@set_context
def _send_cluster_metrics(self, ctx):
if not CONF.drivers.send_cluster_metrics:
LOG.debug('Skip sending cluster metrics')
return
LOG.debug('Starting to send cluster metrics')
for cluster in objects.Cluster.list(ctx):
if cluster.status not in (

View File

@ -332,3 +332,30 @@ class PeriodicTestCase(base.TestCase):
self.assertEqual(1, mock_create_monitor.call_count)
self.assertEqual(0, notifier.info.call_count)
@mock.patch('magnum.conductor.monitors.create_monitor')
@mock.patch('magnum.objects.Cluster.list')
@mock.patch('magnum.common.rpc.get_notifier')
@mock.patch('magnum.common.context.make_admin_context')
def test_send_cluster_metrics_disable_pull_data(
self, mock_make_admin_context, mock_get_notifier,
mock_cluster_list, mock_create_monitor):
mock_make_admin_context.return_value = self.context
notifier = mock.MagicMock()
mock_get_notifier.return_value = notifier
mock_cluster_list.return_value = [self.cluster1, self.cluster2,
self.cluster3, self.cluster4]
self.cluster4.status = cluster_status.CREATE_COMPLETE
monitor = mock.MagicMock()
monitor.get_metric_names.return_value = ['metric1', 'metric2']
monitor.compute_metric_value.return_value = 30
monitor.get_metric_unit.return_value = '%'
mock_create_monitor.return_value = monitor
CONF.set_override('send_cluster_metrics',
False, group='drivers')
periodic.MagnumPeriodicTasks(CONF)._send_cluster_metrics(self.context)
self.assertEqual(0, mock_create_monitor.call_count)
self.assertEqual(0, notifier.info.call_count)