Merge lp:~stylesen/lava-scheduler/multinode into lp:lava-scheduler/multinode

Proposed by Senthil Kumaran S
Status: Merged
Approved by: Neil Williams
Approved revision: no longer in the source branch.
Merged at revision: 256
Proposed branch: lp:~stylesen/lava-scheduler/multinode
Merge into: lp:lava-scheduler/multinode
Diff against target: 108 lines (+46/-5)
4 files modified
lava_scheduler_app/models.py (+4/-1)
lava_scheduler_daemon/dbjobsource.py (+38/-2)
lava_scheduler_daemon/job.py (+4/-1)
lava_scheduler_daemon/service.py (+0/-1)
To merge this branch: bzr merge lp:~stylesen/lava-scheduler/multinode
Reviewer Review Type Date Requested Status
Linaro Automation & Validation Pending
Review via email: mp+172282@code.launchpad.net

Description of the change

Make the job based scheduler aware of health check jobs and schedule it properly.

To post a comment you must log in.
256. By Neil Williams

Senthil Kumaran 2013-07-01 Make the job based scheduler aware of health check jobs and schedule it

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-06-27 12:17:42 +0000
3+++ lava_scheduler_app/models.py 2013-07-01 08:02:44 +0000
4@@ -522,7 +522,10 @@
5 description=job_name, health_check=health_check, user=user,
6 group=group, is_public=is_public, priority=priority)
7 job.save()
8- return job.id
9+ if health_check == True:
10+ return job
11+ else:
12+ return job.id
13
14 def _can_admin(self, user):
15 """ used to check for things like if the user can cancel or annotate
16
17=== modified file 'lava_scheduler_daemon/dbjobsource.py'
18--- lava_scheduler_daemon/dbjobsource.py 2013-06-27 11:26:26 +0000
19+++ lava_scheduler_daemon/dbjobsource.py 2013-07-01 08:02:44 +0000
20@@ -103,6 +103,39 @@
21 def getBoardList(self):
22 return self.deferForDB(self.getBoardList_impl)
23
24+ def _get_health_check_jobs(self):
25+ """Gets the list of configured boards and checks which are the boards
26+ that require health check.
27+
28+ Returns JOB_LIST which is a list of health check jobs. If no health
29+ check jobs are available returns an empty list.
30+ """
31+ job_list = []
32+ configured_boards = [
33+ x.hostname for x in dispatcher_config.get_devices()]
34+ boards = []
35+ for d in Device.objects.all():
36+ if d.hostname in configured_boards:
37+ boards.append(d)
38+
39+ for device in boards:
40+ if device.status != Device.IDLE:
41+ continue
42+ if not device.device_type.health_check_job:
43+ run_health_check = False
44+ elif device.health_status == Device.HEALTH_UNKNOWN:
45+ run_health_check = True
46+ elif device.health_status == Device.HEALTH_LOOPING:
47+ run_health_check = True
48+ elif not device.last_health_report_job:
49+ run_health_check = True
50+ else:
51+ run_health_check = device.last_health_report_job.end_time < \
52+ datetime.datetime.now() - datetime.timedelta(days=1)
53+ if run_health_check:
54+ job_list.append(self._getHealthCheckJobForBoard(device))
55+ return job_list
56+
57 def _fix_device(self, device, job):
58 """Associate an available/idle DEVICE to the given JOB.
59
60@@ -141,7 +174,7 @@
61 def getJobList_impl(self):
62 jobs = TestJob.objects.all().filter(
63 status=TestJob.SUBMITTED).order_by('-priority', 'submit_time')
64- job_list = []
65+ job_list = self._get_health_check_jobs()
66 devices = None
67
68 for job in jobs:
69@@ -172,7 +205,10 @@
70
71 def _get_json_data(self, job):
72 json_data = simplejson.loads(job.definition)
73- json_data['target'] = job.actual_device.hostname
74+ if job.actual_device:
75+ json_data['target'] = job.actual_device.hostname
76+ elif job.requested_device:
77+ json_data['target'] = job.requested_device.hostname
78 for action in json_data['actions']:
79 if not action['command'].startswith('submit_results'):
80 continue
81
82=== modified file 'lava_scheduler_daemon/job.py'
83--- lava_scheduler_daemon/job.py 2013-06-20 11:45:50 +0000
84+++ lava_scheduler_daemon/job.py 2013-07-01 08:02:44 +0000
85@@ -31,7 +31,10 @@
86 self.reactor = reactor
87 self.daemon_options = daemon_options
88 self.job = job
89- self.board_name = job.actual_device.hostname
90+ if job.actual_device:
91+ self.board_name = job.actual_device.hostname
92+ elif job.requested_device:
93+ self.board_name = job.requested_device.hostname
94 if job_cls is not None:
95 self.job_cls = job_cls
96 self.running_job = None
97
98=== modified file 'lava_scheduler_daemon/service.py'
99--- lava_scheduler_daemon/service.py 2013-06-20 11:41:39 +0000
100+++ lava_scheduler_daemon/service.py 2013-07-01 08:02:44 +0000
101@@ -77,7 +77,6 @@
102
103 def _cbCheckJobs(self, job_list):
104 for job in job_list:
105- self.logger.debug("Found job: %d" % job.id)
106 new_job = NewJob(self.source, job, self.dispatcher, self.reactor,
107 self.daemon_options)
108 self.logger.info("Starting Job: %d " % job.id)

Subscribers

People subscribed via source and target branches

to status/vote changes: