pluggable notification agent

event, meter (and any other custom pipeline) can be enabled/disabled
by setting `pipelines` option under [notification] agent

Change-Id: Ia21256d0308457d077836e27b45d2acb8bb697e4
Closes-Bug: #1720021
This commit is contained in:
gord chung 2017-11-03 20:01:02 +00:00
parent c82d28d9db
commit 60d9b87a80
4 changed files with 45 additions and 4 deletions

View File

@ -24,9 +24,10 @@ from futurist import periodics
from oslo_config import cfg
from oslo_log import log
import oslo_messaging
from stevedore import extension
from stevedore import named
from tooz import coordination
from ceilometer.i18n import _
from ceilometer import messaging
from ceilometer import utils
@ -75,7 +76,11 @@ OPTS = [
deprecated_group='DEFAULT',
deprecated_name='notification_workers',
help='Number of workers for notification service, '
'default value is 1.')
'default value is 1.'),
cfg.MultiStrOpt('pipelines',
default=['meter', 'event'],
help="Select which pipeline managers to enable to "
" generate data"),
]
@ -139,6 +144,9 @@ class NotificationService(cotyledon.Service):
for exchange in
set(self.conf.notification.notification_control_exchanges)]
def _log_missing_pipeline(self, names):
LOG.error(_('Could not load the following pipelines: %s'), names)
def run(self):
# Delay startup so workers are jittered
time.sleep(self.startup_delay)
@ -146,8 +154,10 @@ class NotificationService(cotyledon.Service):
super(NotificationService, self).run()
self.coord_lock = threading.Lock()
self.managers = [ext.obj for ext in extension.ExtensionManager(
namespace='ceilometer.notification.pipeline', invoke_on_load=True,
self.managers = [ext.obj for ext in named.NamedExtensionManager(
namespace='ceilometer.notification.pipeline',
names=self.conf.notification.pipelines, invoke_on_load=True,
on_missing_entrypoints_callback=self._log_missing_pipeline,
invoke_args=(self.conf,
self.conf.notification.workload_partitioning))]

View File

@ -121,6 +121,23 @@ class TestNotification(BaseNotificationTest):
self.assertEqual(1, len(mock_listener.call_args_list[0][0][1]))
self.assertEqual(1, len(self.srv.listeners))
def test_select_pipelines(self):
self.CONF.set_override('pipelines', ['event'], group='notification')
self.srv.run()
self.addCleanup(self.srv.terminate)
self.assertEqual(1, len(self.srv.managers))
self.assertEqual(1, len(self.srv.listeners[0].dispatcher.endpoints))
@mock.patch('ceilometer.notification.LOG')
def test_select_pipelines_missing(self, logger):
self.CONF.set_override('pipelines', ['meter', 'event', 'bad'],
group='notification')
self.srv.run()
self.addCleanup(self.srv.terminate)
self.assertEqual(2, len(self.srv.managers))
logger.error.assert_called_with(
'Could not load the following pipelines: %s', set(['bad']))
class BaseRealNotification(BaseNotificationTest):
def setup_pipeline(self, counter_names):

View File

@ -39,6 +39,10 @@ The notification agent is responsible for consuming notifications. This
component is responsible for consuming from the message bus and transforming
notifications into events and measurement samples.
By default, the notification agent is configured to build both events and
samples. To enable selective data models, set the required pipelines using
`pipelines` option under the `[notification]` section.
Additionally, the notification agent is responsible for all data processing
such as transformations and publishing. After processing, the data is sent
to any supported publisher target such as gnocchi or panko. These services

View File

@ -0,0 +1,10 @@
---
features:
- |
The notification-agent can now be configured to either build meters or
events. By default, the notification agent will continue to load both
pipelines and build both data models. To selectively enable a pipeline,
configure the `pipelines` option under the `[notification]` section.
Addition pipelines can be created following the format used by existing
pipelines.