From 36e124a19754af105acece863749484db01a77b5 Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Tue, 7 Mar 2023 08:52:39 +0100 Subject: [PATCH] Try to always download build log files It seems that currently Zuul provides more information about builds even when it is not "SUCCESS", "FAILUE" or "TIMED_OUT". Let's try to download the log files when the log_url is provided. Change-Id: Ic40c67e0bf78a75931ceae55824f5664b9aada14 --- logscraper/logscraper.py | 13 +++---------- logscraper/tests/test_logscraper.py | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/logscraper/logscraper.py b/logscraper/logscraper.py index 04977d5..739dd53 100755 --- a/logscraper/logscraper.py +++ b/logscraper/logscraper.py @@ -560,13 +560,6 @@ def download_file(url, directory, insecure, timeout): logging.critical("Can not decode content from %s" % url) -def is_job_with_result(job_result): - results_with_status = ['failure', 'success', 'timed_out'] - if (job_result["result"].lower() in results_with_status and - job_result["log_url"]): - return True - - def create_custom_result(job_result, directory): try: with open("%s/custom-job-results.txt" % directory, "w") as f: @@ -687,11 +680,11 @@ def run_build(build): validate_ca = _verify_ca(args) - if is_job_with_result(build): + if 'log_url' in build and build["log_url"]: check_specified_files(build, validate_ca, args.timeout, directory) else: - # NOTE: if build result is "ABORTED" or "NODE_FAILURE, there is - # no any job result files to parse, but we would like to have that + # NOTE: if build result does not contain 'log_url', so there is + # no result files to parse, but we would like to have that # knowledge, so it will create own job-results.txt file that # contains: # build["end_time"] | build["result"] diff --git a/logscraper/tests/test_logscraper.py b/logscraper/tests/test_logscraper.py index 6303a56..c38bfd2 100644 --- a/logscraper/tests/test_logscraper.py +++ b/logscraper/tests/test_logscraper.py @@ -440,7 +440,7 @@ class TestScraper(base.TestCase): workers=1, download=True, directory="/tmp/testdir")) def test_run_aborted_download(self, mock_args, mock_gear, mock_gear_client, mock_check_files, mock_custom_result): - # Take job result that build_status is "ABORTED" or "NODE_FAILURE" + # Take job result that log_url is empty. result = builds_result[2] result['files'] = ['job-output.txt'] result['tenant'] = 'sometenant'