Skip to content

Commit

Permalink
worker: improve handling of missing or inaccessible task results
Browse files Browse the repository at this point in the history
  • Loading branch information
lzaoral committed Sep 12, 2023
1 parent 2216d13 commit 6964c37
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
14 changes: 10 additions & 4 deletions osh/worker/tasks/task_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion osh/worker/tasks/task_errata_diff_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})",
Expand Down
9 changes: 8 additions & 1 deletion osh/worker/tasks/task_get_analyzer_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})",
Expand Down

0 comments on commit 6964c37

Please sign in to comment.