mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Don't save job filtered job lists in variables. Handle service not found error.
This commit is contained in:
parent
a86ae5c75c
commit
be0241519d
@ -10,11 +10,7 @@ def checkout_jobs():
|
|||||||
with scheduler.app.app_context():
|
with scheduler.app.app_context():
|
||||||
client = docker.from_env()
|
client = docker.from_env()
|
||||||
jobs = db.session.query(Job)
|
jobs = db.session.query(Job)
|
||||||
submitted_jobs = jobs.filter_by(status='submitted').all()
|
for job in jobs.filter_by(status='submitted').all():
|
||||||
foo_jobs = jobs.filter(Job.status != 'complete',
|
|
||||||
Job.status != 'failed',
|
|
||||||
Job.status != 'submitted').all()
|
|
||||||
for job in submitted_jobs:
|
|
||||||
_command = (job.service
|
_command = (job.service
|
||||||
+ ' -i /files'
|
+ ' -i /files'
|
||||||
+ ' -o /files/output'
|
+ ' -o /files/output'
|
||||||
@ -65,13 +61,15 @@ def checkout_jobs():
|
|||||||
restart_policy=_restart_policy
|
restart_policy=_restart_policy
|
||||||
)
|
)
|
||||||
job.status = 'scheduled'
|
job.status = 'scheduled'
|
||||||
for job in foo_jobs:
|
for job in jobs.filter(Job.status != 'complete',
|
||||||
'''
|
Job.status != 'failed',
|
||||||
' TODO: Handle service not found error.
|
Job.status != 'submitted').all():
|
||||||
'''
|
try:
|
||||||
service = client.services.get(str(job.id))
|
service = client.services.get(str(job.id))
|
||||||
job.status = service.tasks()[0].get('Status').get('State')
|
job.status = service.tasks()[0].get('Status').get('State')
|
||||||
if job.status == 'complete' or job.status == 'failed':
|
if job.status == 'complete' or job.status == 'failed':
|
||||||
job.end_date = datetime.utcnow()
|
job.end_date = datetime.utcnow()
|
||||||
service.remove()
|
service.remove()
|
||||||
|
except docker.errors.NotFound:
|
||||||
|
job.status = 'failed'
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user