diff --git a/osh/worker/tasks/task_build.py b/osh/worker/tasks/task_build.py index 72a1377ee..19ba653df 100644 --- a/osh/worker/tasks/task_build.py +++ b/osh/worker/tasks/task_build.py @@ -69,12 +69,18 @@ def run(self): else: print("No srpm specified", file=sys.stderr) self.fail() + if results is None: - print("No results available", file=sys.stderr) + print("Task did not produce any results", file=sys.stderr) + self.fail() + + try: + base_results = os.path.basename(results) + with open(results, "rb") as f: + self.hub.upload_task_log(f, self.task_id, base_results) + except OSError as e: + print("Reading task logs failed:", e, file=sys.stderr) self.fail() - base_results = os.path.basename(results) - with open(results, "rb") as f: - self.hub.upload_task_log(f, self.task_id, base_results) # first finish task, then fail if needed, so tarball gets unpacked self.hub.worker.finish_task(self.task_id) diff --git a/osh/worker/tasks/task_errata_diff_build.py b/osh/worker/tasks/task_errata_diff_build.py index af0fe6ef8..8ffa30acc 100644 --- a/osh/worker/tasks/task_errata_diff_build.py +++ b/osh/worker/tasks/task_errata_diff_build.py @@ -77,10 +77,19 @@ def run(self): koji_profile=koji_profile, su_user=su_user) print('Retcode:', retcode) - if results is not None: + if results is None: + print("Task did not produce any results", file=sys.stderr) + self.hub.worker.fail_scan(scan_id, 'Empty task results') + self.fail() + + try: base_results = os.path.basename(results) with open(results, 'rb') as f: self.hub.upload_task_log(f, self.task_id, base_results) + except OSError as e: + print("Reading task logs failed:", e, file=sys.stderr) + self.hub.worker.fail_scan(scan_id, f'Reading tak logs failed: {e}') + self.fail() if retcode > 0: print(f"Scanning has not completed successfully ({retcode})", diff --git a/osh/worker/tasks/task_get_analyzer_versions.py b/osh/worker/tasks/task_get_analyzer_versions.py index cdd21ff5b..a3ac3f084 100644 --- a/osh/worker/tasks/task_get_analyzer_versions.py +++ b/osh/worker/tasks/task_get_analyzer_versions.py @@ -44,10 +44,17 @@ def run(self): print('Retcode:', retcode) # upload results back to hub - if results is not None: + if results is None: + print("Task did not produce any results", file=sys.stderr) + self.fail() + + try: base_results = os.path.basename(results) with open(results, "rb") as f: self.hub.upload_task_log(f, self.task_id, base_results) + except OSError as e: + print("Reading task logs failed:", e, file=sys.stderr) + self.fail() if retcode > 0: print(f"Analyzer version retrieval has not completed successfully ({retcode})",