-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/WP-189 Handle timeout exit code for interactive app jobs (#851)
* added success message and state for interactive job on timeout * linting * created a central utility function, added logic to determine timeout * remove commented code * Added a comment
- Loading branch information
1 parent
24783bc
commit e2e3e5b
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import json | ||
|
||
|
||
def get_tapis_timeout_error_messages(job_id): | ||
return [ | ||
'JOBS_EARLY_TERMINATION Job terminated by Tapis because: TIME_EXPIRED', | ||
f'JOBS_USER_APP_FAILURE The user application ({job_id}) ended with remote status "TIMEOUT" and returned exit code: 0:0.' | ||
] | ||
|
||
|
||
def check_job_for_timeout(job): | ||
""" | ||
Check an interactive job for timeout status and mark it as finished | ||
since Tapis does not have native support for interactive jobs yet | ||
""" | ||
|
||
if (hasattr(job, 'notes')): | ||
notes = json.loads(job.notes) | ||
|
||
is_failed = job.status == 'FAILED' | ||
is_interactive = notes.get('isInteractive', False) | ||
has_timeout_message = job.lastMessage in get_tapis_timeout_error_messages(job.remoteJobId) | ||
|
||
if is_failed and is_interactive and has_timeout_message: | ||
job.status = 'FINISHED' | ||
job.remoteOutcome = 'FINISHED' | ||
|
||
return job |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters