Commit ce0a353f authored by Guillaume Tucker's avatar Guillaume Tucker
Browse files

Only try to get current job when device is running in all_devices()



For some reason yet unknown, calling `.current_job()` on a Device
object when its state is not "running" can cause some server errors.
This is likely to be due to some discrepancy in the database.  The
schedule.all_devices() XMLRPC call causes an HTTP502 when this
happens.  Work around this problem by only looking for the current job
of devices that are in the running state.
Signed-off-by: Guillaume Tucker's avatarGuillaume Tucker <guillaume.tucker@collabora.com>
parent c2b3619d
......@@ -310,15 +310,20 @@ class SchedulerAPI(ExposedV2API):
health=Device.HEALTH_RETIRED
)
devices_jobs = ((
dev,
dev.current_job() if dev.state == Device.STATE_RUNNING else None
) for dev in devices_list)
return [
[
dev.hostname,
dev.device_type.name,
build_device_status_display(dev.state, dev.health),
dev.current_job().pk if dev.current_job() else None,
job.pk if job else None,
True,
]
for dev in devices_list
for dev, job in devices_jobs
]
def all_device_types(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment