From e2a792a1c71fa7b1d3d8bbb821943bbf4a882ac6 Mon Sep 17 00:00:00 2001 From: Idan Hefetz Date: Thu, 14 Nov 2019 08:38:18 +0000 Subject: [PATCH] Bugfix - Processor check if neighbors are newer before updating them The bug is that the processor may update a vertex to an older timestamp than the existing. Change-Id: I67e4c59fc1170b07e8f7c50416de8e8598152f09 --- vitrage/entity_graph/processor/processor.py | 17 +++++++++++------ .../evaluator/test_action_executor.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/vitrage/entity_graph/processor/processor.py b/vitrage/entity_graph/processor/processor.py index 3733944de..9dd31f492 100644 --- a/vitrage/entity_graph/processor/processor.py +++ b/vitrage/entity_graph/processor/processor.py @@ -219,12 +219,17 @@ class Processor(processor.ProcessorBase): for (vertex, edge) in neighbors: graph_vertex = self.entity_graph.get_vertex(vertex.vertex_id) if not graph_vertex or not PUtils.is_deleted(graph_vertex): - LOG.debug("Updates vertex: %s", vertex) - self._calculate_vitrage_aggregated_values(vertex, action) - PUtils.update_entity_graph_vertex(self.entity_graph, - graph_vertex, - vertex) - + if graph_vertex and not PUtils.is_newer_vertex(graph_vertex, + vertex): + LOG.warning("Neighbor update event arrived later than " + "expected - graph_vertex: %s --- " + "updated_vertex: %s", graph_vertex, vertex) + else: + LOG.debug("Updates vertex: %s", vertex) + self._calculate_vitrage_aggregated_values(vertex, action) + PUtils.update_entity_graph_vertex(self.entity_graph, + graph_vertex, + vertex) if edge not in valid_edges: LOG.debug("Updates edge: %s", edge) self.entity_graph.update_edge(edge) diff --git a/vitrage/tests/functional/evaluator/test_action_executor.py b/vitrage/tests/functional/evaluator/test_action_executor.py index e17f91bf3..30d3fdb9d 100644 --- a/vitrage/tests/functional/evaluator/test_action_executor.py +++ b/vitrage/tests/functional/evaluator/test_action_executor.py @@ -354,7 +354,7 @@ class TestActionExecutor(TestFunctionalBase, TestConfiguration): NProps.STATUS_INFO: 'test test test', DSProp.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT, DSProp.ENTITY_TYPE: NAGIOS_DATASOURCE, - DSProp.SAMPLE_DATE: '2016-02-07 15:26:04'} + DSProp.SAMPLE_DATE: '2016-02-07T15:26:04Z'} @staticmethod def _get_vitrage_add_vertex_event(target_vertex, alarm_name, severity):