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 <>
parent c2b3619d
...@@ -310,15 +310,20 @@ class SchedulerAPI(ExposedV2API): ...@@ -310,15 +310,20 @@ class SchedulerAPI(ExposedV2API):
health=Device.HEALTH_RETIRED health=Device.HEALTH_RETIRED
) )
devices_jobs = ((
dev.current_job() if dev.state == Device.STATE_RUNNING else None
) for dev in devices_list)
return [ return [
[ [
dev.hostname, dev.hostname,,,
build_device_status_display(dev.state,, build_device_status_display(dev.state,,
dev.current_job().pk if dev.current_job() else None, if job else None,
True, True,
] ]
for dev in devices_list for dev, job in devices_jobs
] ]
def all_device_types(self): 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