diff --git a/atvm/watcher-service/atvm_run_watcher.py b/atvm/watcher-service/atvm_run_watcher.py index cef7bb4..cc75130 100644 --- a/atvm/watcher-service/atvm_run_watcher.py +++ b/atvm/watcher-service/atvm_run_watcher.py @@ -342,6 +342,29 @@ def collect_host_results( return results +def collect_latest_host_result( + reporter_root: Path, + expected_hosts: List[str], + kernels: Dict[str, str], + run_started_at: datetime, + run_ended_at: Optional[datetime] = None, +) -> Optional[Tuple[str, HostResult]]: + results = collect_host_results( + reporter_root=reporter_root, + expected_hosts=expected_hosts, + kernels=kernels, + run_started_at=run_started_at, + run_ended_at=run_ended_at, + ) + if not results: + return None + latest = max( + results.items(), + key=lambda item: item[1].timestamp or datetime.fromtimestamp(0, tz=timezone.utc), + ) + return latest + + def find_check_xml_end( reporter_root: Path, started_at: datetime, @@ -748,6 +771,19 @@ def discover_categorized_subruns( if summary and (not host_results or all(result.host == "check-xml-files" for result in host_results.values())): host_results = summary["host_results"] completed_hosts.extend([host for host in host_results if host not in completed_hosts]) + if not host_results and check_ts: + latest_host = collect_latest_host_result( + reporter_root=reporter_root, + expected_hosts=expected_hosts, + kernels=inventory, + run_started_at=started_at, + run_ended_at=check_ts + timedelta(seconds=5), + ) + if latest_host: + host, result = latest_host + host_results = {host: result} + if host not in completed_hosts: + completed_hosts.append(host) if summary: current_summary_index += 1 state = "RUNNING" @@ -763,6 +799,8 @@ def discover_categorized_subruns( notes.append("Final `check-xml-files.ts` validation passed.") if summary and host_results: notes.append("Host result details were derived from the parent categorized run log summary.") + elif host_results and check_ts: + notes.append("Host result details were derived from the latest matching host reporter artifact written before grouped finalization.") elif check_ts and not host_results and parent_active: notes.append("Grouped reporter XML arrived before the parent run log exposed the final host summary; waiting to post until host details are available.") if display_name != raw_display_name: