Merge lp:~gary/charms/precise/buildbot-master/add-max-builds-support into lp:~yellow/charms/oneiric/buildbot-master/trunk

Proposed by Gary Poster
Status: Needs review
Proposed branch: lp:~gary/charms/precise/buildbot-master/add-max-builds-support
Merge into: lp:~yellow/charms/oneiric/buildbot-master/trunk
Diff against target: 74 lines (+17/-8)
2 files modified
hooks/buildbot-relation-changed (+11/-3)
hooks/wrapper.cfg (+6/-5)
To merge this branch: bzr merge lp:~gary/charms/precise/buildbot-master/add-max-builds-support
Reviewer Review Type Date Requested Status
Yellow Squad Pending
Review via email: mp+106925@code.launchpad.net

Description of the change

This adds max-builds support for the charm. It needs buildbot-slave support also, available in lp:~gary/charms/precise/buildbot-slave/add-max-builds-support .

To post a comment you must log in.

Unmerged revisions

44. By Gary Poster

add max_builds option for slaves

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/buildbot-relation-changed'
2--- hooks/buildbot-relation-changed 2012-02-29 22:43:30 +0000
3+++ hooks/buildbot-relation-changed 2012-05-23 01:39:21 +0000
4@@ -20,26 +20,34 @@
5 )
6
7
8-def update_slave_json(builders):
9+def update_slave_json(builders, max_builds):
10 name = os.getenv('JUJU_REMOTE_UNIT')
11 with su('buildbot'):
12 slave_info = slave_json.get()
13 passwd, _ = slave_info.get(name, (None, None))
14 if passwd is None:
15 passwd = generate_string()
16- slave_info[name] = (passwd, builders)
17+ slave_info[name] = (passwd, builders, max_builds)
18 slave_json.set(slave_info)
19 return name, passwd
20
21
22 def main():
23+ log("Retrieving max_builds.")
24+ max_builds = relation_get('max_builds')
25+ if max_builds:
26+ log("max_builds: {}".format(max_builds))
27+ max_builds = int(max_builds)
28+ else:
29+ log("max_builds: infinite (not set))")
30+ max_builds = None
31 log("Retrieving builders.")
32 builders = filter(
33 None,
34 (b.strip() for b in relation_get('builders').split(',')))
35 if builders:
36 log("builders: {}".format(builders))
37- name, passwd = update_slave_json(builders)
38+ name, passwd = update_slave_json(builders, max_builds)
39 log("Reconfiguring buildbot.")
40 buildbot_reconfig()
41 log("Sending name and password to the slave.")
42
43=== modified file 'hooks/wrapper.cfg'
44--- hooks/wrapper.cfg 2012-02-23 20:09:56 +0000
45+++ hooks/wrapper.cfg 2012-05-23 01:39:21 +0000
46@@ -15,22 +15,23 @@
47 # wanted it.
48 c = BuildmasterConfig
49
50-# This is a dict. The keys are the slave names. The values are a
51-# pair of (password, builders). "builders" is a list.
52+# This is a dict. The keys are the slave names. The values are a tuple of
53+# (password, builders, max_builds). "builders" is a list, and "max_builds" is
54+# an int or None.
55 with open('/tmp/slave_info.json') as f:
56 slave_info = json.load(f)
57
58 # Add slaves.
59 from buildbot.buildslave import BuildSlave
60 c['slaves'].append(BuildSlave(name_of_dummy_slave, uuid.uuid4().hex))
61-for name, (passwd, builders) in slave_info.items():
62- c['slaves'].append(BuildSlave(name, passwd))
63+for name, (passwd, builders, max_builds) in slave_info.items():
64+ c['slaves'].append(BuildSlave(name, passwd, max_builds=max_builds))
65
66 # Add slaves to builders.
67 for builder in c['builders']:
68 name = builder.name
69 current_slaves = list(filter(None, builder.slavenames))
70- for slavename, (passwd, builders) in slave_info.items():
71+ for slavename, (passwd, builders, max_builds) in slave_info.items():
72 if name in builders:
73 current_slaves.append(slavename)
74 if not current_slaves:

Subscribers

People subscribed via source and target branches

to all changes: