Skip to content

Commit

Permalink
Merge pull request #51 from elixir-cloud-aai/fix-job-status
Browse files Browse the repository at this point in the history
Improve check by looping the array.
  • Loading branch information
trispera authored Dec 16, 2024
2 parents f3ac7c2 + eb401be commit a50995a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/tesk_core/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ def run_to_completion(self, poll_interval, check_cancelled, pod_timeout):
def get_status(self, is_all_pods_runnning):
job = self.bv1.read_namespaced_job(self.name, self.namespace)
try:
if job.status.conditions[0].type == 'Complete' and job.status.conditions[0].status:
self.status = 'Complete'
elif job.status.conditions[0].type == 'Failed' and job.status.conditions[0].status:
self.status = 'Failed'
else:
# Loops around the status conditions array, and looks for 'Complete', 'Failed' or
# 'SuccessCriteriaMet'. If none of these are found, the Job is marked as 'Error'
for condition in job.status.conditions:
if condition.type == 'Complete' and condition.status:
self.status = 'Complete'
break
if condition.type == 'Failed' and condition.status:
self.status = 'Failed'
break
if condition.type == 'SuccessCriteriaMet' and condition.status:
self.status = 'Complete'
break
self.status = 'Error'
except TypeError: # The condition is not initialized, so it is not complete yet, wait for it
self.status = 'Running'
Expand Down

0 comments on commit a50995a

Please sign in to comment.