How can I run a task on job termination once per job?
- Dominant language
- No language data
- Stars
- 27
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
What I'd like to do is something like:
```
try {
// run all regular tasks
} finally {
// run a final termination task, once per job, not per node
// the termination task shall run whether the job completed normally or was terminated early
}
```
In my case, the final termination task would query the Batch API and fetch the exit status of each regular task and determine the overall "success" of the job, and then write this into a database.
It seems that this is not directly possible currently. The options are:
1. Abuse the current job release tasks. Since these run per-node, the script that's executed would have to be engineered such that it is OK to run it multiple times.
2. Define the termination task as a regular task which depends on all other tasks. This would only work partly though. If the job is terminated early, then this final task would never run, which defeats the whole point.
Is there anything I'm not considering here? It seems like a fairly basic missing feature.
Contributor guide
Assessment
This issue has not been assessed yet.