mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Catch more exceptions.
This commit is contained in:
parent
be0241519d
commit
3a6fdaa24b
@ -42,14 +42,7 @@ def checkout_jobs():
|
|||||||
mem_reservation=job.mem_mb * (10 ** 6)
|
mem_reservation=job.mem_mb * (10 ** 6)
|
||||||
)
|
)
|
||||||
_restart_policy = docker.types.RestartPolicy(condition='none')
|
_restart_policy = docker.types.RestartPolicy(condition='none')
|
||||||
'''
|
try:
|
||||||
' Create the service with the prepared values.
|
|
||||||
'
|
|
||||||
' Note: A service reserves hardware ressources. In case no worker
|
|
||||||
' node has the required ressources available (not reserved),
|
|
||||||
' the service gets queued by the Docker engine until a node
|
|
||||||
' is able to meet the requirements.
|
|
||||||
'''
|
|
||||||
service = client.services.create(
|
service = client.services.create(
|
||||||
_image,
|
_image,
|
||||||
command=_command,
|
command=_command,
|
||||||
@ -61,6 +54,10 @@ def checkout_jobs():
|
|||||||
restart_policy=_restart_policy
|
restart_policy=_restart_policy
|
||||||
)
|
)
|
||||||
job.status = 'scheduled'
|
job.status = 'scheduled'
|
||||||
|
except docker.errors.APIError:
|
||||||
|
job.status = 'failed'
|
||||||
|
print('[ERROR] {}: client.services.create raised APIError'
|
||||||
|
.format(job.id))
|
||||||
for job in jobs.filter(Job.status != 'complete',
|
for job in jobs.filter(Job.status != 'complete',
|
||||||
Job.status != 'failed',
|
Job.status != 'failed',
|
||||||
Job.status != 'submitted').all():
|
Job.status != 'submitted').all():
|
||||||
@ -70,6 +67,16 @@ def checkout_jobs():
|
|||||||
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.APIError:
|
||||||
|
job.status = 'failed'
|
||||||
|
print('[ERROR] {}: client.services.get raised APIError'
|
||||||
|
.format(job.id))
|
||||||
except docker.errors.NotFound:
|
except docker.errors.NotFound:
|
||||||
job.status = 'failed'
|
job.status = 'failed'
|
||||||
|
print('[ERROR] {}: client.services.get raised NotFound'
|
||||||
|
.format(job.id))
|
||||||
|
except docker.errors.InvalidVersion:
|
||||||
|
job.status = 'failed'
|
||||||
|
print('[ERROR] {}: client.services.get raised InvalidVersion'
|
||||||
|
.format(job.id))
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
Loading…
Reference in New Issue
Block a user