From 1cc7087af12c4fa66396a6642725014bdfa48d56 Mon Sep 17 00:00:00 2001 From: Ryota MIBU Date: Fri, 7 Aug 2015 12:38:56 +0900 Subject: [PATCH] Exclude event type from targets of alarm evaluator The new evaluator service will be added to handle 'event' type alarms only. Existing evaluator have to exclude those 'event' type alarms from their targets which will be evaluated periodically. Change-Id: Ia501771ee8d3dcd424c7e415d8aeb3d41a8e8de0 Implements: blueprint event-alarm-evaluator --- aodh/evaluator/__init__.py | 6 +++++- aodh/tests/test_evaluator.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/aodh/evaluator/__init__.py b/aodh/evaluator/__init__.py index dbb03af0..b9bb819d 100644 --- a/aodh/evaluator/__init__.py +++ b/aodh/evaluator/__init__.py @@ -259,6 +259,10 @@ class AlarmEvaluationService(AlarmService, os_service.Service): self.tg.add_timer(604800, lambda: None) def _assigned_alarms(self): - all_alarms = self._storage_conn.get_alarms(enabled=True) + # NOTE(r-mibu): The 'event' type alarms will be evaluated by the + # event-driven alarm evaluator, so this periodical evaluator skips + # those alarms. + all_alarms = self._storage_conn.get_alarms(enabled=True, + exclude=dict(type='event')) return self.partition_coordinator.extract_my_subset( self.PARTITIONING_GROUP_NAME, all_alarms) diff --git a/aodh/tests/test_evaluator.py b/aodh/tests/test_evaluator.py index eb4afcf5..8a7fbe31 100644 --- a/aodh/tests/test_evaluator.py +++ b/aodh/tests/test_evaluator.py @@ -135,3 +135,13 @@ class TestAlarmEvaluationService(tests_base.BaseTestCase): self.svc.start() self.svc._evaluate_assigned_alarms() self.threshold_eval.evaluate.assert_called_once_with(alarms[1]) + + def test_check_alarm_query_constraints(self): + self.storage_conn.get_alarms.return_value = [] + with mock.patch('aodh.storage.get_connection_from_config', + return_value=self.storage_conn): + self.svc.start() + self.svc._evaluate_assigned_alarms() + expected = [({'enabled': True, 'exclude': {'type': 'event'}},)] + self.assertEqual(expected, + self.storage_conn.get_alarms.call_args_list)