Skip to content
Snippets Groups Projects
Commit 3a6fdaa2 authored by Patrick Jentsch's avatar Patrick Jentsch
Browse files

Catch more exceptions.

parent be024151
No related branches found
No related tags found
No related merge requests found
...@@ -42,25 +42,22 @@ def checkout_jobs(): ...@@ -42,25 +42,22 @@ 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. service = client.services.create(
' _image,
' Note: A service reserves hardware ressources. In case no worker command=_command,
' node has the required ressources available (not reserved), constraints=_constraints,
' the service gets queued by the Docker engine until a node labels=_labels,
' is able to meet the requirements. mounts=_mounts,
''' name=_name,
service = client.services.create( resources=_resources,
_image, restart_policy=_restart_policy
command=_command, )
constraints=_constraints, job.status = 'scheduled'
labels=_labels, except docker.errors.APIError:
mounts=_mounts, job.status = 'failed'
name=_name, print('[ERROR] {}: client.services.create raised APIError'
resources=_resources, .format(job.id))
restart_policy=_restart_policy
)
job.status = 'scheduled'
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(): ...@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment