Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve check by looping the array. #51

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
trispera marked this conversation as resolved.
Show resolved Hide resolved
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'
trispera marked this conversation as resolved.
Show resolved Hide resolved
except TypeError: # The condition is not initialized, so it is not complete yet, wait for it
self.status = 'Running'
Expand Down
Loading