]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Emit alarm actions if a rule remains in ALARM state.
authorSteve Baker <sbaker@redhat.com>
Mon, 24 Jun 2013 02:19:36 +0000 (14:19 +1200)
committerSteve Baker <sbaker@redhat.com>
Mon, 24 Jun 2013 02:19:36 +0000 (14:19 +1200)
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

heat/engine/watchrule.py
heat/tests/test_watch.py

index e6db474b66cf9e06ceea4a50b337aeccc98e9ab7..0a70ac9333ef9f7bada16f560d00ebc8b67378dd 100644 (file)
@@ -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()
index 5066cd081d041e39f2511254a5ae243ac85ce83f..1c342dd7042e21469b34209e3568ba5aac59113d 100644 (file)
@@ -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):