Skip to content
Snippets Groups Projects
Verified Commit f54dd511 authored by Dorian Koch's avatar Dorian Koch
Browse files

Don't immediately delete everything after processing

parent a607687e
Branches
Tags v1.0.2
No related merge requests found
Pipeline #6475 passed
...@@ -11,3 +11,8 @@ POSTGRES = { ...@@ -11,3 +11,8 @@ POSTGRES = {
"database": "videoag" "database": "videoag"
} }
''' '''
# Whether to immediately delete jobs after they have been processed
# Ideally everything that is needed will be extracted from the job and stored in the database, so this should be set to True
DELETE_JOBS_AFTER_SUCCESS = True
DELETE_JOBS_AFTER_FAILURE = False
...@@ -40,13 +40,16 @@ class WrappedJob(Event): ...@@ -40,13 +40,16 @@ class WrappedJob(Event):
if self.job_state == JobState.FINISHED: if self.job_state == JobState.FINISHED:
self.success(cstate) self.success(cstate)
self.jobData.update_state(cstate, JobState.FINISHED_AND_PROCESSED) self.jobData.update_state(cstate, JobState.FINISHED_AND_PROCESSED)
if cstate.config.get("DELETE_JOBS_AFTER_SUCCESS", True):
cstate.k8s.delete_job_by_id(self.job_id)
elif self.job_state == JobState.FAILED: elif self.job_state == JobState.FAILED:
self.failure(cstate) self.failure(cstate)
self.jobData.update_state(cstate, JobState.FAILED_AND_PROCESSED) self.jobData.update_state(cstate, JobState.FAILED_AND_PROCESSED)
if cstate.config.get("DELETE_JOBS_AFTER_FAILURE", True):
cstate.k8s.delete_job_by_id(self.job_id)
else: else:
raise Exception(f"Job is in unexpected state: {self.job_state}") raise Exception(f"Job is in unexpected state: {self.job_state}")
# delete from k8s
cstate.k8s.delete_job_by_id(self.job_id)
# update state to processed # update state to processed
if self.job_state == JobState.FINISHED_AND_PROCESSED or self.job_state == JobState.FAILED_AND_PROCESSED: if self.job_state == JobState.FINISHED_AND_PROCESSED or self.job_state == JobState.FAILED_AND_PROCESSED:
return EventResult.DONE return EventResult.DONE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment