From: Steve Baker Date: Mon, 24 Jun 2013 02:19:36 +0000 (+1200) Subject: Emit alarm actions if a rule remains in ALARM state. X-Git-Tag: 2014.1~445^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bdeb33afdc52f37c2270a72c2221b051024f3f3f;p=openstack-build%2Fheat-build.git Emit alarm actions if a rule remains in ALARM state. It looks like the original intent of this edge-triggering was to prevent actions being emitted too frequently, causing overshoot of scaling resources. However this causes an issue when one scaling resource change is not enough to bring the alarm state under the threshold. Proper use of Period, EvaluationPeriods and Threshold should be sufficient to prevent scaling resource overshoot. Fixes bug: #1193970 Change-Id: I5b38eb82cd1ad568fe4af77999e9d52f9eb99328 --- diff --git a/heat/engine/watchrule.py b/heat/engine/watchrule.py index e6db474b..0a70ac93 100644 --- a/heat/engine/watchrule.py +++ b/heat/engine/watchrule.py @@ -216,11 +216,8 @@ class WatchRule(object): def run_rule(self): new_state = self.get_alarm_state() - - actions = [] - if new_state != self.state: - actions = self.rule_actions(new_state) - self.state = new_state + actions = self.rule_actions(new_state) + self.state = new_state self.last_evaluated = self.now self.store() diff --git a/heat/tests/test_watch.py b/heat/tests/test_watch.py index 5066cd08..1c342dd7 100644 --- a/heat/tests/test_watch.py +++ b/heat/tests/test_watch.py @@ -439,14 +439,12 @@ class WatchRuleTest(HeatTestCase): self.assertEqual(watcher.state, 'ALARM') self.assertEqual(actions, ['DummyAction']) - # re-set last_evaluated so the rule will be evaluated again, - # but since we're already in ALARM state, we should not generate - # any additional actions + # re-set last_evaluated so the rule will be evaluated again. last = now - datetime.timedelta(seconds=300) watcher.last_evaluated = last actions = watcher.evaluate() self.assertEqual(watcher.state, 'ALARM') - self.assertEqual(actions, []) + self.assertEqual(actions, ['DummyAction']) self.m.VerifyAll() def test_rule_actions_alarm_two_actions(self):