From 75b2c47db7f3c092b8bfa47de8e49036041762cc Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Tue, 4 Aug 2015 16:49:21 +0200 Subject: [PATCH] gnocchi: percent_of_overlap=0 for agg. alarms In case of a heat autoscaling stack decide to delete an instance, the gnocchi metrics associated to this instance will be no more updated and when the alarm will ask for the aggregation, gnocchi will raise a 'No overlap' exception. So temporary set 'percent_of_overlap' to 0 to disable the gnocchi checks about missing points. And adds some docs about the importance of filter out resource with ended_at != 'null'. For more detail see: https://bugs.launchpad.net/gnocchi/+bug/1479429 Related bug: #1479429 Change-Id: I528d21c048d84b9552febd08f787812c668983ab --- aodh/api/controllers/v2/alarm_rules/gnocchi.py | 5 ++++- aodh/evaluator/gnocchi.py | 8 ++++++++ aodh/tests/evaluator/test_gnocchi.py | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/aodh/api/controllers/v2/alarm_rules/gnocchi.py b/aodh/api/controllers/v2/alarm_rules/gnocchi.py index 45f1717d2..57fbed16d 100644 --- a/aodh/api/controllers/v2/alarm_rules/gnocchi.py +++ b/aodh/api/controllers/v2/alarm_rules/gnocchi.py @@ -123,7 +123,10 @@ class AggregationMetricByResourcesLookupRule(AlarmGnocchiThresholdRule): "The name of the metric" query = wsme.wsattr(wtypes.text, mandatory=True) - "The query to filter the metric" + ('The query to filter the metric, Don\'t forget to filter out ' + 'deleted resources (example: {"and": [{"=": {"ended_at": null}}, ...]}), ' + 'Otherwise Gnocchi will try to create the aggregate against obsolete ' + 'resources') resource_type = wsme.wsattr(wtypes.text, mandatory=True) "The resource type" diff --git a/aodh/evaluator/gnocchi.py b/aodh/evaluator/gnocchi.py index d2526f23e..629885d1c 100644 --- a/aodh/evaluator/gnocchi.py +++ b/aodh/evaluator/gnocchi.py @@ -60,6 +60,14 @@ class GnocchiThresholdEvaluator(threshold.ThresholdEvaluator): req['url'] += "/aggregation/resource/%s/metric/%s" % ( alarm.rule['resource_type'], alarm.rule['metric']) req['data'] = alarm.rule['query'] + # FIXME(sileht): In case of a heat autoscaling stack decide to + # delete an instance, the gnocchi metrics associated to this + # instance will be no more updated and when the alarm will ask + # for the aggregation, gnocchi will raise a 'No overlap' exception. + # So temporary set 'percent_of_overlap' to 0 to disable the + # gnocchi checks about missing points. For more detail see: + # https://bugs.launchpad.net/gnocchi/+bug/1479429 + req['params']['percent_of_overlap'] = 0 elif alarm.type == 'gnocchi_aggregation_by_metrics_threshold': req['url'] += "/aggregation/metric" diff --git a/aodh/tests/evaluator/test_gnocchi.py b/aodh/tests/evaluator/test_gnocchi.py index bd7d9883c..b98c81c76 100644 --- a/aodh/tests/evaluator/test_gnocchi.py +++ b/aodh/tests/evaluator/test_gnocchi.py @@ -227,7 +227,8 @@ class TestGnocchiThresholdEvaluate(base.TestEvaluatorBase): mock.call(url='http://localhost:8041/v1/aggregation/resource/' 'instance/metric/cpu_util', params={'aggregation': 'mean', - 'start': start_alarm3, 'end': end}, + 'start': start_alarm3, 'end': end, + 'percent_of_overlap': 0}, data='{"=": {"server_group": "my_autoscaling_group"}}', headers=expected_headers), ],