Merge lp:~cjwatson/launchpad/rearrange-builders into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: no longer in the source branch.
Merged at revision: 17412
Proposed branch: lp:~cjwatson/launchpad/rearrange-builders
Merge into: lp:launchpad
Diff against target: 362 lines (+100/-75)
5 files modified
lib/lp/buildmaster/browser/builder.py (+35/-10)
lib/lp/buildmaster/templates/builders-index.pt (+30/-32)
lib/lp/soyuz/browser/tests/builder-views.txt (+7/-7)
lib/lp/soyuz/stories/soyuz/xx-builder-page.txt (+6/-5)
lib/lp/soyuz/stories/soyuz/xx-buildfarm-index.txt (+22/-21)
To merge this branch: bzr merge lp:~cjwatson/launchpad/rearrange-builders
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+253818@code.launchpad.net

Commit message

Show a category row above each per-virtualisation/processors "clump" of builders, allowing us to remove the overflowing Architectures column.

Description of the change

Show a category row above each per-virtualisation/processors "clump" of builders, allowing us to remove the overflowing Architectures column. An example of the resulting page is attached to https://bugs.launchpad.net/launchpad/+bug/1435275.

This sacrifices the ability to sort this table, but as a frequent user of this page I've generally found that to be more of a footgun than a useful feature anyway.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)
Revision history for this message
Colin Watson (cjwatson) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/buildmaster/browser/builder.py'
2--- lib/lp/buildmaster/browser/builder.py 2014-06-20 11:52:32 +0000
3+++ lib/lp/buildmaster/browser/builder.py 2015-03-23 12:07:22 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2014 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Browser views for builders."""
10@@ -16,6 +16,7 @@
11 'BuilderView',
12 ]
13
14+from itertools import groupby
15 import operator
16
17 from lazr.restful.utils import smartquote
18@@ -37,8 +38,6 @@
19 IBuilder,
20 IBuilderSet,
21 )
22-from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
23-from lp.buildmaster.model.buildqueue import BuildQueue
24 from lp.code.interfaces.sourcepackagerecipebuild import (
25 ISourcePackageRecipeBuildSource,
26 )
27@@ -144,13 +143,26 @@
28 def page_title(self):
29 return self.label
30
31+ @staticmethod
32+ def getBuilderSortKey(builder):
33+ return (
34+ builder.virtualized,
35+ tuple(p.id for p in builder.processors),
36+ builder.name)
37+
38 @cachedproperty
39 def builders(self):
40 """All active builders"""
41 builders = list(self.context.getBuilders())
42- return list(sorted(
43- builders, key=lambda b: (
44- b.virtualized, tuple(p.id for p in b.processors), b.name)))
45+ return list(sorted(builders, key=self.getBuilderSortKey))
46+
47+ @property
48+ def builder_clumps(self):
49+ """Active builders grouped by virtualization and processors."""
50+ return [
51+ BuilderClump(list(group))
52+ for _, group in groupby(
53+ self.builders, lambda b: self.getBuilderSortKey(b)[:-1])]
54
55 @property
56 def number_of_registered_builders(self):
57@@ -176,21 +188,34 @@
58
59 @property
60 def virt_builders(self):
61- """Return a BuilderCategory object for PPA builders."""
62+ """Return a BuilderCategory object for virtual builders."""
63 builder_category = BuilderCategory(
64- 'PPA build status', virtualized=True)
65+ 'Virtual build status', virtualized=True)
66 builder_category.groupBuilders(self.builders, self.build_queue_sizes)
67 return builder_category
68
69 @property
70 def nonvirt_builders(self):
71- """Return a BuilderCategory object for PPA builders."""
72+ """Return a BuilderCategory object for non-virtual builders."""
73 builder_category = BuilderCategory(
74- 'Official distributions build status', virtualized=False)
75+ 'Non-virtual build status', virtualized=False)
76 builder_category.groupBuilders(self.builders, self.build_queue_sizes)
77 return builder_category
78
79
80+class BuilderClump:
81+ """A "clump" of builders with the same virtualization and processors.
82+
83+ The name came in desperation from a thesaurus; BuilderGroup and
84+ BuilderCategory are already in use here for slightly different kinds of
85+ grouping.
86+ """
87+ def __init__(self, builders):
88+ self.virtualized = builders[0].virtualized
89+ self.processors = builders[0].processors
90+ self.builders = builders
91+
92+
93 class BuilderGroup:
94 """A group of builders for the processor.
95
96
97=== modified file 'lib/lp/buildmaster/templates/builders-index.pt'
98--- lib/lp/buildmaster/templates/builders-index.pt 2013-12-03 04:51:48 +0000
99+++ lib/lp/buildmaster/templates/builders-index.pt 2015-03-23 12:07:22 +0000
100@@ -44,44 +44,42 @@
101 <div class="first yui-u">
102 <div id="builders-list" class="portlet">
103 <h2>Builders</h2>
104- <table class="listing sortable" id="builders-table">
105+ <table class="listing" id="builders-table">
106 <thead>
107 <tr>
108 <th></th>
109 <th>Name</th>
110- <th>Architectures</th>
111 <th>Status</th>
112 </tr>
113 </thead>
114 <tbody>
115- <tr class="builder-row" tal:repeat="builder view/builders">
116- <td class="icon left">
117- <span class="sortkey" tal:content="builder/virtualized" />
118- <img src="/@@/ppa-icon" alt="[ppa]" title="PPA builder"
119- tal:condition="builder/virtualized" />
120- <img src="/@@/distribution" alt="[official]"
121- title="Official builder"
122- tal:condition="not: builder/virtualized" />
123- </td>
124- <td style="width: 9em;">
125- <span class="sortkey" tal:content="builder/name" />
126- <a tal:attributes="href builder/fmt:url"
127- tal:content="builder/name">Bob</a>
128- </td>
129- <td style="width: 9em;">
130- <span class="sortkey">
131- <tal:processor repeat="processor builder/processors"
132- content="processor/name">386</tal:processor>
133- </span>
134- <tal:repeat repeat="processor builder/processors">
135- <tal:processor replace="processor/name">386</tal:processor>
136- </tal:repeat>
137- </td>
138- <td tal:define="job builder/currentjob">
139- <metal:status-summary
140- use-macro="builder/@@+index/status-summary" />
141- </td>
142- </tr>
143+ <tal:clump tal:repeat="clump view/builder_clumps">
144+ <tr class="category">
145+ <td class="icon left">
146+ <img src="/@@/ppa-icon" alt="[virtual]"
147+ title="Virtual builder"
148+ tal:condition="clump/virtualized" />
149+ <img src="/@@/distribution" alt="[non-virtual]"
150+ title="Non-virtual builder"
151+ tal:condition="not: clump/virtualized" />
152+ </td>
153+ <td colspan="2">
154+ <tal:processor repeat="processor clump/processors"
155+ content="processor/name" />
156+ </td>
157+ </tr>
158+ <tr class="builder-row" tal:repeat="builder clump/builders">
159+ <td></td>
160+ <td style="width: 9em;">
161+ <a tal:attributes="href builder/fmt:url"
162+ tal:content="builder/name">Bob</a>
163+ </td>
164+ <td tal:define="job builder/currentjob">
165+ <metal:status-summary
166+ use-macro="builder/@@+index/status-summary" />
167+ </td>
168+ </tr>
169+ </tal:clump>
170 </tbody>
171 </table>
172 <p tal:condition="view/user">
173@@ -92,7 +90,7 @@
174 </div><!-- yui-u -->
175
176 <div class="yui-u">
177- <div id="official-queue-status" class="portlet">
178+ <div id="nonvirt-queue-status" class="portlet">
179 <div tal:define="category view/nonvirt_builders">
180 <div metal:use-macro="template/macros/builder-category" />
181 </div>
182@@ -100,7 +98,7 @@
183 </div><!-- yui-u -->
184
185 <div class="yui-u">
186- <div id="ppa-queue-status" class="portlet">
187+ <div id="virt-queue-status" class="portlet">
188 <div tal:define="category view/virt_builders">
189 <div metal:use-macro="template/macros/builder-category" />
190 </div>
191
192=== modified file 'lib/lp/soyuz/browser/tests/builder-views.txt'
193--- lib/lp/soyuz/browser/tests/builder-views.txt 2014-06-20 12:21:49 +0000
194+++ lib/lp/soyuz/browser/tests/builder-views.txt 2015-03-23 12:07:22 +0000
195@@ -234,11 +234,11 @@
196 BuilderSetView offer a way to treat the currently registered builders
197 in categories. They are:
198
199- * 'Official distribution build machines': a group of builders capable
200- of building 'trusted' sources, ubuntu official packages. The
201- 'non-vitualized' build-farm.
202+ * 'Non-virtual build machines': a group of builders capable of building
203+ 'trusted' sources, Ubuntu official packages. The 'non-virtualized'
204+ build-farm.
205
206- * 'PPA build machines': a group of builders capable of building
207+ * 'Virtual build machines': a group of builders capable of building
208 'untrusted' sources, PPA packages. The 'virtualized' build-farm.
209
210 >>> from lp.buildmaster.interfaces.builder import IBuilderSet
211@@ -296,7 +296,7 @@
212 <...BuilderCategory ...>
213
214 >>> print builder_category.title
215- Official distributions build status
216+ Non-virtual build status
217
218 >>> print builder_category.virtualized
219 False
220@@ -346,13 +346,13 @@
221 >>> print i386_group.duration
222 0:00:30
223
224-The 'PPA' builder category is also available in BuilderSetView as a
225+The 'virtual' builder category is also available in BuilderSetView as a
226 `BuilderCategory`.
227
228 >>> builder_category = builderset_view.virt_builders
229
230 >>> print builder_category.title
231- PPA build status
232+ Virtual build status
233
234 >>> print builder_category.virtualized
235 True
236
237=== modified file 'lib/lp/soyuz/stories/soyuz/xx-builder-page.txt'
238--- lib/lp/soyuz/stories/soyuz/xx-builder-page.txt 2014-06-20 07:59:21 +0000
239+++ lib/lp/soyuz/stories/soyuz/xx-builder-page.txt 2015-03-23 12:07:22 +0000
240@@ -261,13 +261,14 @@
241 1 available build machine, 1 disabled and 0 building of a total
242 of 2 registered.
243 Builders
244- Name Architectures Status
245- frog 386 Disabled
246- victim 386 Idle
247+ Name Status
248+ 386
249+ frog Disabled
250+ victim Idle
251 Updated on ...
252- Official distributions build status
253+ Non-virtual build status
254 Architecture Builders Queue
255- PPA build status
256+ Virtual build status
257 Architecture Builders Queue
258 386 1 empty
259
260
261=== modified file 'lib/lp/soyuz/stories/soyuz/xx-buildfarm-index.txt'
262--- lib/lp/soyuz/stories/soyuz/xx-buildfarm-index.txt 2014-06-20 08:32:31 +0000
263+++ lib/lp/soyuz/stories/soyuz/xx-buildfarm-index.txt 2015-03-23 12:07:22 +0000
264@@ -8,7 +8,7 @@
265 >>> anon_browser.open('http://launchpad.dev/+builds')
266
267 The BuildFarm contains a list of all builders registered in Launchpad
268-ordered by build domain ('official' then 'ppa'), then processor and
269+ordered by build domain ('nonvirt' then 'virt'), then processor and
270 finally by name. A short textual description of their status is listed
271 in the 'Status' column. There are also 2 portlets on the right-side
272 containing the build queue status summary for each build domain.
273@@ -18,13 +18,14 @@
274 1 available build machine, 1 disabled and 1 building of a total of
275 2 registered.
276 Builders
277- Name Architectures Status
278- bob 386 Building i386 build of mozilla-firefox 0.9 ...
279- frog 386 Disabled
280- Official distributions build status
281+ Name Status
282+ 386
283+ bob Building i386 build of mozilla-firefox 0.9 ...
284+ frog Disabled
285+ Non-virtual build status
286 Architecture Builders Queue
287 386 1 1 job (1 minute)
288- PPA build status
289+ Virtual build status
290 Architecture Builders Queue
291 386 0 empty
292
293@@ -37,26 +38,26 @@
294
295 The build status portlets contain the number of builds waiting
296 in queue and the sum of their 'estimated_duration' for each
297-supported processor on each separated build domain, 'official'
298-(PRIMARY and PARTNER) and 'ppa'.
299+supported processor on each separated build domain, 'nonvirt'
300+(PRIMARY and PARTNER) and 'virt'.
301
302 >>> anon_browser.reload()
303 >>> print extract_text(
304- ... find_tag_by_id(anon_browser.contents, 'official-queue-status'))
305- Official distributions build status
306+ ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status'))
307+ Non-virtual build status
308 Architecture Builders Queue
309 386 1 1 job (1 minute)
310
311 >>> print extract_text(
312- ... find_tag_by_id(anon_browser.contents, 'ppa-queue-status',))
313- PPA build status
314+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status',))
315+ Virtual build status
316 Architecture Builders Queue
317 386 0 empty
318
319-When there are pending builds in the PPA domain, they are listed in
320+When there are pending builds in the virt domain, they are listed in
321 the corresponding portlet with their estimated duration as well.
322
323- # Retry a failed build in the PPA domain and set its
324+ # Retry a failed build in the virt domain and set its
325 # 'estimated_duration' to a known value.
326 >>> import datetime
327 >>> from zope.component import getUtility
328@@ -75,13 +76,13 @@
329
330 >>> anon_browser.reload()
331 >>> print extract_text(
332- ... find_tag_by_id(anon_browser.contents, 'ppa-queue-status'))
333- PPA build status
334+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status'))
335+ Virtual build status
336 Architecture Builders Queue
337 386 0 1 job (1 minute)
338
339 If the archive for the build does not require virtual builders, then
340-the pending job will appear in the 'official' queue. Since the build
341+the pending job will appear in the 'nonvirt' queue. Since the build
342 record already exists, we must manually set it to non-virtualized too.
343
344 >>> login('foo.bar@canonical.com')
345@@ -91,14 +92,14 @@
346
347 >>> anon_browser.reload()
348 >>> print extract_text(
349- ... find_tag_by_id(anon_browser.contents, 'ppa-queue-status'))
350- PPA build status
351+ ... find_tag_by_id(anon_browser.contents, 'virt-queue-status'))
352+ Virtual build status
353 Architecture Builders Queue
354 386 0 empty
355
356 >>> print extract_text(
357- ... find_tag_by_id(anon_browser.contents, 'official-queue-status'))
358- Official distributions build status
359+ ... find_tag_by_id(anon_browser.contents, 'nonvirt-queue-status'))
360+ Non-virtual build status
361 Architecture Builders Queue
362 386 1 2 jobs (2 minutes)
363