Module: check_mk
Branch: master
Commit: 3ed42d19657b897d54eefbc2224e76aeaaec0b28
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3ed42d19657b89…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Mar 8 13:49:37 2019 +0100
7234 FIX Fixed broken event cancelling by priority (1.5.0p12 regression)
When a EC rule is configured to cancel an open event by priority and the lower
priority level is the left of the priority range, the cancelling was not
working.
For example EMERG to CRIT worked while CRIT to EMERG did not work. This has
been fixed. The order of both levels should not be relevant for the processing
of the rules.
Change-Id: I7a285338fb1c716b50503c37fe0b3b55a27fd364
---
.werks/7234 | 16 ++++++++++++++++
cmk/ec/main.py | 6 ++----
tests/unit/cmk/ec/test_rule_matching.py | 10 ++++++++++
3 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/.werks/7234 b/.werks/7234
new file mode 100644
index 0000000..4a94b8e
--- /dev/null
+++ b/.werks/7234
@@ -0,0 +1,16 @@
+Title: Fixed broken event cancelling by priority (1.5.0p12 regression)
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1552049108
+Class: fix
+
+When a EC rule is configured to cancel an open event by priority and the lower
+priority level is the left of the priority range, the cancelling was not
+working.
+
+For example EMERG to CRIT worked while CRIT to EMERG did not work. This has
+been fixed. The order of both levels should not be relevant for the processing
+of the rules.
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index 2fe1eee..d2a5761 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -2367,15 +2367,13 @@ class RuleMatcher(object):
p = event["priority"]
if "match_priority" in rule:
- prio_from, prio_to = rule["match_priority"]
- if prio_from > prio_to:
- prio_to, prio_from = prio_from, prio_to
+ prio_from, prio_to = sorted(rule["match_priority"])
match_priority["has_match"] = prio_from <= p <= prio_to
else:
match_priority["has_match"] = True
if "cancel_priority" in rule:
- cancel_from, cancel_to = rule["cancel_priority"]
+ cancel_from, cancel_to = sorted(rule["cancel_priority"])
match_priority["has_canceling_match"] = cancel_from <= p <=
cancel_to
else:
match_priority["has_canceling_match"] = False
diff --git a/tests/unit/cmk/ec/test_rule_matching.py
b/tests/unit/cmk/ec/test_rule_matching.py
index 3b70e0b..96aec86 100644
--- a/tests/unit/cmk/ec/test_rule_matching.py
+++ b/tests/unit/cmk/ec/test_rule_matching.py
@@ -67,6 +67,10 @@ def test_match_message(m, message, result, match_message,
cancel_message, match_
(2, (2, 2), None, True, False, True),
(2, (1, 1), None, False, False, False),
(2, (3, 5), None, False, False, False),
+ (2, (10, 0), None, True, False, True),
+ (2, (2, 2), None, True, False, True),
+ (2, (1, 1), None, False, False, False),
+ (2, (5, 3), None, False, False, False),
# cancel
(2, None, (2, 2), True, True, True),
(2, (3, 5), (2, 2), False, True, True),
@@ -74,6 +78,12 @@ def test_match_message(m, message, result, match_message,
cancel_message, match_
(2, None, (1, 1), True, False, True),
(2, None, (3, 5), True, False, True),
(2, (3, 5), (3, 5), False, False, False),
+ (2, None, (2, 2), True, True, True),
+ (2, (5, 3), (2, 2), False, True, True),
+ (2, None, (10, 0), True, True, True),
+ (2, None, (1, 1), True, False, True),
+ (2, None, (5, 3), True, False, True),
+ (2, (5, 3), (5, 3), False, False, False),
# positive + cancel
(2, (2, 2), (2, 2), True, True, True),
])