| |
@@ -106,6 +106,38 @@
|
| |
cache, subject_type, subject_identifier, testcase=None)
|
| |
|
| |
|
| |
+ def _equals_except_keys(lhs, rhs, except_keys):
|
| |
+ keys = lhs.keys() - except_keys
|
| |
+ return lhs.keys() == rhs.keys() \
|
| |
+ and all(lhs[key] == rhs[key] for key in keys)
|
| |
+
|
| |
+
|
| |
+ def _is_decision_unchanged(old_decision, decision):
|
| |
+ """
|
| |
+ Returns true only if new decision is same as old one
|
| |
+ (ignores result_id values).
|
| |
+ """
|
| |
+ if old_decision is None or decision is None:
|
| |
+ return old_decision == decision
|
| |
+
|
| |
+ requirements_keys = ('satisfied_requirements', 'unsatisfied_requirements')
|
| |
+ if not _equals_except_keys(old_decision, decision, requirements_keys):
|
| |
+ return False
|
| |
+
|
| |
+ ignore_keys = ('result_id',)
|
| |
+ for key in requirements_keys:
|
| |
+ old_requirements = old_decision[key]
|
| |
+ requirements = decision[key]
|
| |
+ if len(old_requirements) != len(requirements):
|
| |
+ return False
|
| |
+
|
| |
+ for old_requirement, requirement in zip(old_requirements, requirements):
|
| |
+ if not _equals_except_keys(old_requirement, requirement, ignore_keys):
|
| |
+ return False
|
| |
+
|
| |
+ return True
|
| |
+
|
| |
+
|
| |
class ResultsDBHandler(fedmsg.consumers.FedmsgConsumer):
|
| |
"""
|
| |
Handle a new result.
|
| |
@@ -254,7 +286,7 @@
|
| |
log.exception('Failed to retrieve decision for data=%s, error: %s', data, e)
|
| |
continue
|
| |
|
| |
- if decision == old_decision:
|
| |
+ if _is_decision_unchanged(old_decision, decision):
|
| |
log.debug('Skipped emitting fedmsg, decision did not change: %s', decision)
|
| |
else:
|
| |
decision.update({
|
| |
When Greenwave receives new result message from ResultsDB it tries to
compare old decision (ignoring the new result) with new one (for all its
policies) so it can publish decision update message only when the
decision changed.
The new decision was seen as "changed" when any of its data differ from
the old decision. The problem is that decision data include result IDs
so it's always seen as "changed" if the new result is part of the new
decision.
Example:
With this change, the new decision is seen as "changed" when any of its
data changes except result IDs.
Fixes #395
Signed-off-by: Lukas Holecek hluk@email.cz