fix BUG-98 (user cancel of a job not dealing with dependant jobs) & constrain the width of the chosen face in DBox for overrides/create refimg

This commit is contained in:
2022-07-19 20:45:54 +10:00
parent 382647a91b
commit fd79ee2cf4
4 changed files with 36 additions and 14 deletions

35
job.py
View File

@@ -104,6 +104,31 @@ def NewJob(name, num_files="0", wait_for=None, jex=None ):
WakePAJobManager()
return job
################################################################################
# WithdrawDependantJobs: for a stale job (pa_job_mgr restarts and a job is not
# finished), this function is called if the user chooses to cancel the job. It
# cancels this job, and any dependant jobs as well
################################################################################
def WithdrawDependantJobs( job, id, reason ):
for j in Job.query.filter(Job.wait_for==id).all():
FinishJob(j, f"Job (#{j.id}) has been cancelled -- #{job.id} {reason}", "Withdrawn" )
WithdrawDependantJobs(j, j.id, reason)
return
##############################################################################
# FinishJob(): finish this job off (if no overrides), its just marked completed
##############################################################################
def FinishJob(job, last_log, state="Completed", pa_job_state="Completed"):
job.state=state
job.pa_job_state=pa_job_state
job.last_update=datetime.now(pytz.utc)
log=Joblog( job_id=job.id, log=last_log, log_date=job.last_update )
db.session.add(log)
if job.state=="Failed":
WithdrawDependantJobs( job, job.id, "dependant job failed" )
db.session.commit()
return
################################################################################
# /jobs -> show jobs (default to only showing 'non-archived' jobs -- age is in
# settings.job_archive_age
@@ -185,13 +210,11 @@ def stale_job(id):
job.num_files=0
job.current_file=''
job.current_file_num=0
job.last_update=now
db.session.add(log)
elif request.form['action'] == "cancel":
log=Joblog( job_id=id, log="(Stale) Job withdrawn manually by user", log_date=now )
job.pa_job_state='Completed'
job.state='Withdrawn'
job.last_update=now
db.session.add(log)
WithdrawDependantJobs( job, job.id, "(Stale) Job withdrawn manually by user" )
FinishJob(job, f"Job (#{job.id}) (Stale) Job withdrawn manually by user", "Withdrawn" )
# clear out message for this job being stale (and do this via raw sql to
# avoid circulr import)