Merge lp:~codehelp/lava-scheduler/submitting-offline into lp:lava-scheduler

Proposed by Neil Williams
Status: Merged
Approved by: Neil Williams
Approved revision: 260
Merged at revision: 259
Proposed branch: lp:~codehelp/lava-scheduler/submitting-offline
Merge into: lp:lava-scheduler
Diff against target: 21 lines (+4/-2)
1 file modified
lava_scheduler_app/models.py (+4/-2)
To merge this branch: bzr merge lp:~codehelp/lava-scheduler/submitting-offline
Reviewer Review Type Date Requested Status
Neil Williams Approve
Antonio Terceiro Approve
Review via email: mp+183854@code.launchpad.net

Description of the change

Allow submission of jobs when devices are offline by only excluding devices which are retired from the calculation of available devices.

Currently built out on playground.v.l.o

To post a comment you must log in.
Revision history for this message
Neil Williams (codehelp) wrote :

It works for singlenode jobs but something is still not right for multinode - I'm investigating.

review: Needs Fixing
Revision history for this message
Neil Williams (codehelp) wrote :

With the ~ negation, the device_types hash always returns 1, not the number of boards with a state other than the one specified.
On playground:
arndale 2 idle, 0 offline, 0 busy
kvm 0 idle, 2 offline, 0 busy
Submitting a MultiNode job for 2 KVMs gave:
Required number of device(s) 2 ([(u'arndale', 1), (u'kvm', 1)]) unavailable.
where the exception was changed to output:
"Required number of device(s) %d (%s) unavailable." % (count, device_types))

The alternative code (which adds OFFLINE to the original filter) is more messy and would need more ongoing maintenance when new states are added, but simple negation doesn't give us the results we expected.

    device_types = DeviceType.objects.values_list('name').filter(
        models.Q(device__status=Device.IDLE) |
        models.Q(device__status=Device.RUNNING) |
        models.Q(device__status=Device.RESERVED) |
        models.Q(device__status=Device.OFFLINE)
        ).annotate(
            num_count=models.Count('name')
        ).order_by('name')

With that change and deliberately testing with a MultiNode job which asks for 3 devices instead of 2:
Required number of device(s) 3 ([(u'arndale', 2), (u'kvm', 2)]) unavailable.

The state of the boards themselves did not change between these tests.

The original MultiNode job asking for 2 KVMs was submitted correctly on playground with the more expansive change.

I'll update the branch and this MP.

Revision history for this message
Neil Williams (codehelp) wrote :

Also changing the exception message to give something like:
Requested 3 kvm device(s) - only 2 available.

260. By Neil Williams

Change to an explicit check for boards which are offlining, reserved or
already offline to allow job submission as long as the boards
are not retired. Clarify exception message.

Revision history for this message
Neil Williams (codehelp) :
review: Needs Resubmitting
Revision history for this message
Antonio Terceiro (terceiro) wrote :

Looks good to me

review: Approve
Revision history for this message
Neil Williams (codehelp) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_scheduler_app/models.py'
2--- lava_scheduler_app/models.py 2013-09-02 15:42:27 +0000
3+++ lava_scheduler_app/models.py 2013-09-04 14:48:56 +0000
4@@ -62,7 +62,9 @@
5 device_types = DeviceType.objects.values_list('name').filter(
6 models.Q(device__status=Device.IDLE) |
7 models.Q(device__status=Device.RUNNING) |
8- models.Q(device__status=Device.RESERVED)
9+ models.Q(device__status=Device.RESERVED) |
10+ models.Q(device__status=Device.OFFLINE) |
11+ models.Q(device__status=Device.OFFLINING)
12 ).annotate(
13 num_count=models.Count('name')
14 ).order_by('name')
15@@ -79,7 +81,7 @@
16 continue
17 else:
18 raise DevicesUnavailableException(
19- "Required number of device(s) unavailable.")
20+ "Requested %d %s device(s) - only %d available." % (count, board, all_devices[board]))
21 return True
22
23

Subscribers

People subscribed via source and target branches