Skip to content

Commit

Permalink
Improve check by looping the array.
Browse files Browse the repository at this point in the history
It will consider the job complete for 'Complete' and 'SuccessCriteriaMet' types. Still mark Failed jobs as Failed and set the rest as error
  • Loading branch information
lvarin committed Dec 16, 2024
1 parent f3ac7c2 commit eb401be
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 eb401be

Please sign in to comment.