Skip to content

Commit f8fcb19

Browse files
authored
feat(DM01-5915): upload archive files on job timeout (#597)
* feat(DM01-5915): upload archive files on job timeout * fix avg_duration
1 parent dc34cfe commit f8fcb19

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/api/handlers/job_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ def post(self):
10751075
AND j.state = 'finished'
10761076
""", [project_id, project_id, build_number - 10, build_number, job['name']])[0]
10771077

1078-
job['avg_duration'] = avg_duration if avg_duration is not None else 0
1078+
job['avg_duration'] = float(avg_duration) if avg_duration is not None else 0
10791079

10801080
if not job['env_vars']:
10811081
job['env_vars'] = {}

src/scheduler/kubernetes/scheduler.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,12 @@ def handle_timeouts(self):
926926
WHERE id = %s and state = 'running' """, (job_id,))
927927
cursor.close()
928928

929+
# Delete the k8s resource so the pod receives SIGTERM and has
930+
# terminationGracePeriodSeconds (60s) to run finalize_upload(),
931+
# which uploads /infrabox/upload/archive. kube_delete_job is
932+
# idempotent — safe if the resource is already being deleted.
933+
self.kube_delete_job(job_id)
934+
929935
def upload_console(self, job_id):
930936
cursor = self.conn.cursor()
931937
cursor.execute("begin")

0 commit comments

Comments
 (0)