Merge lp://staging/~qzhang/lava-scheduler/add-labhealth-page into lp://staging/lava-scheduler
Proposed by
Paul Larson
Status: | Merged |
---|---|
Approved by: | Michael Hudson-Doyle |
Approved revision: | 132 |
Merged at revision: | 132 |
Proposed branch: | lp://staging/~qzhang/lava-scheduler/add-labhealth-page |
Merge into: | lp://staging/lava-scheduler |
Diff against target: |
622 lines (+481/-2) 10 files modified
lava_scheduler_app/migrations/0014_auto__add_field_device_health_status__add_field_device_last_health_rep.py (+124/-0) lava_scheduler_app/migrations/0015_auto__add_field_testjob_health_check.py (+119/-0) lava_scheduler_app/models.py (+29/-2) lava_scheduler_app/templates/lava_scheduler_app/device.html (+4/-0) lava_scheduler_app/templates/lava_scheduler_app/health_jobs.html (+105/-0) lava_scheduler_app/templates/lava_scheduler_app/index.html (+4/-0) lava_scheduler_app/templates/lava_scheduler_app/labhealth.html (+43/-0) lava_scheduler_app/urls.py (+6/-0) lava_scheduler_app/views.py (+38/-0) lava_scheduler_daemon/dbjobsource.py (+9/-0) |
To merge this branch: | bzr merge lp://staging/~qzhang/lava-scheduler/add-labhealth-page |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hudson-Doyle (community) | Approve | ||
Spring Zhang (community) | Needs Resubmitting | ||
Zygmunt Krynicki (community) | Needs Fixing | ||
Review via email:
|
Description of the change
Springz's lab health view... proposing so we can see it easier.
To post a comment you must log in.
General comment: Since I did not realize this was a part of the scheduler app earlier I tend to think (now) that DeviceHealth should be merged with the Device model.
167 + device = models. ForeignKey( Device, verbose_ name=_( u"Device" ))
Do you expect to have more than one instance of DeviceHealth for a given Device (as in, historic device health). If not then consider changing this to be OneToOneField or at least add unique=True
175 + last_report_time = models. DateTimeField(
176 + verbose_name = _(u"Last Report Time"),
177 + auto_now = False,
178 + null = True,
179 + blank = True,
180 + )
What is this field for? Is it any different to last_report_job.
187 + def put_into_ sick(self) : healthy( self):
188 + self.status = self.SICK
189 + self.save()
190 +
191 + def put_into_
192 + self.status = self.HEALTHY
193 + self.save()
IMHO there is nothing wrong with just self.status = self.HEALTY (or STATUS_HEALTY). We should definitely avoid calling .save() as that is separate responsibility (and the few methods that really really need to call save have a should_save=True) argument as well to override this.
157 + UNKNOWN = 0
158 + HEALTHY = 1
159 + SICK = 2
I'd prepend STATUS_ to each and use range(3) as in STATUS_UNKNOWN, STATUS_HEALTHY, STATUS_SICK = range(3)
195 + def latest_job(self): objects. select_ related( device= self.device. hostname, _contains= "lab health" 'end_time' )
196 + return TestJob.
197 + "actual_device",
198 + "description",
199 + "status",
200 + "end_time"
201 + ).filter(
202 + actual_
203 + description_
204 + ).latest(
IMHO the condition to filter on description_ _contains device health is far too loose. It will forever special case two words that may otherwise be used by anything. Doing this (adding hidden foreign keys based on some string value / pattern) is not very good practice. This will also be quite slow as you always need to scan the TestJob table.
I'd suggest an alternative:
1) Use observer pattern to spot bundles as they show up in the system
2) Define a configurable bundle stream for lab health (more on that later)
3) If a bundle is added to that stream update/create DeviceHealth instances
On configuration: Currently it's okay to hardcode certain configuration pieces. This will change in the future. I just wrote and remove a long description of the upcoming changes not to muddy the water here.
221 +<h2><a href="{% url lava.scheduler. labhealth. all %}">Lab Health</a></h2>
282 + url(r'^ labhealth/ $', scheduler. labhealth. all'),
283 + 'lab_health',
284 + name='lava.
Please use a more descriptive URL name, 'lava.scheduler .lab-health' sounds better to me.
+ {% for devicehealth in labhealth %}
Please use device_health_list instead of labhealth (django naming pattern for templates)
313 +@BreadCrumb("All Device Health", parent=index) request) : objects. select_ related( device. status != Device.OFFLINE: latest_ job() put_into_ healthy( ) INCOMPLET. ..
314 +def lab_health(
315 + labhealth = DeviceHealth.
316 + "device", "status").all()
317 + for devicehealth in labhealth:
318 + try:
319 + if devicehealth.
320 + latest_job = devicehealth.
321 + if latest_job.status == TestJob.COMPLETE:
322 + devicehealth.
323 + if latest_job.status == TestJob.