From e4156155854681a39879f805b498f2d5653431e4 Mon Sep 17 00:00:00 2001 From: SteBaum Date: Wed, 31 Jul 2024 12:21:12 +0200 Subject: [PATCH] fix: only generate stales for deployed services --- tdp/dao.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tdp/dao.py b/tdp/dao.py index 7ce011c0..ec7b2976 100644 --- a/tdp/dao.py +++ b/tdp/dao.py @@ -349,6 +349,14 @@ def generate_stale_sch_logs( if len(modified_entities) == 0: return set() + # Get the list of services of the current hosted_entities in the database + hosted_entities: list[HostedEntity] = [ + entity_status.entity for entity_status in hosted_entity_status + ] + hosted_entity_services: list[str] = [ + entity.name.service for entity in hosted_entities + ] + # Create logs for the modified entities for entity in modified_entities: config_operation = collections.operations.get(f"{entity.name}_config") @@ -365,7 +373,12 @@ def generate_stale_sch_logs( # restart operations are available # Only source hosts affected by the modified configuration are considered as # stale (while all hosts are considered as stale for the descendants) - if config_operation or restart_operation: + if ( + config_operation + and entity in hosted_entities + or restart_operation + and entity in hosted_entities + ): log = logs.setdefault( entity, SCHStatusLogModel( @@ -389,7 +402,10 @@ def generate_stale_sch_logs( nodes=list(source_reconfigure_operations), restart=True ): # Only create a log when config or restart operation is available - if operation.action_name not in ["config", "restart"]: + if ( + operation.action_name not in ["config", "restart"] + or operation.service_name not in hosted_entity_services + ): continue # Create a log for each host where the entity is deployed