yellow team mailing list archive
-
yellow team
-
Mailing list archive
-
Message #00871
[Merge] lp:~gary/charms/precise/buildbot-master/add-max-builds-support into lp:~yellow/charms/oneiric/buildbot-master/trunk
Gary Poster has proposed merging lp:~gary/charms/precise/buildbot-master/add-max-builds-support into lp:~yellow/charms/oneiric/buildbot-master/trunk.
Requested reviews:
Launchpad Yellow Squad (yellow)
For more details, see:
https://code.launchpad.net/~gary/charms/precise/buildbot-master/add-max-builds-support/+merge/106925
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 .
--
https://code.launchpad.net/~gary/charms/precise/buildbot-master/add-max-builds-support/+merge/106925
Your team Launchpad Yellow Squad is requested to review the proposed merge of lp:~gary/charms/precise/buildbot-master/add-max-builds-support into lp:~yellow/charms/oneiric/buildbot-master/trunk.
=== modified file 'hooks/buildbot-relation-changed'
--- hooks/buildbot-relation-changed 2012-02-29 22:43:30 +0000
+++ hooks/buildbot-relation-changed 2012-05-23 01:39:21 +0000
@@ -20,26 +20,34 @@
)
-def update_slave_json(builders):
+def update_slave_json(builders, max_builds):
name = os.getenv('JUJU_REMOTE_UNIT')
with su('buildbot'):
slave_info = slave_json.get()
passwd, _ = slave_info.get(name, (None, None))
if passwd is None:
passwd = generate_string()
- slave_info[name] = (passwd, builders)
+ slave_info[name] = (passwd, builders, max_builds)
slave_json.set(slave_info)
return name, passwd
def main():
+ log("Retrieving max_builds.")
+ max_builds = relation_get('max_builds')
+ if max_builds:
+ log("max_builds: {}".format(max_builds))
+ max_builds = int(max_builds)
+ else:
+ log("max_builds: infinite (not set))")
+ max_builds = None
log("Retrieving builders.")
builders = filter(
None,
(b.strip() for b in relation_get('builders').split(',')))
if builders:
log("builders: {}".format(builders))
- name, passwd = update_slave_json(builders)
+ name, passwd = update_slave_json(builders, max_builds)
log("Reconfiguring buildbot.")
buildbot_reconfig()
log("Sending name and password to the slave.")
=== modified file 'hooks/wrapper.cfg'
--- hooks/wrapper.cfg 2012-02-23 20:09:56 +0000
+++ hooks/wrapper.cfg 2012-05-23 01:39:21 +0000
@@ -15,22 +15,23 @@
# wanted it.
c = BuildmasterConfig
-# This is a dict. The keys are the slave names. The values are a
-# pair of (password, builders). "builders" is a list.
+# This is a dict. The keys are the slave names. The values are a tuple of
+# (password, builders, max_builds). "builders" is a list, and "max_builds" is
+# an int or None.
with open('/tmp/slave_info.json') as f:
slave_info = json.load(f)
# Add slaves.
from buildbot.buildslave import BuildSlave
c['slaves'].append(BuildSlave(name_of_dummy_slave, uuid.uuid4().hex))
-for name, (passwd, builders) in slave_info.items():
- c['slaves'].append(BuildSlave(name, passwd))
+for name, (passwd, builders, max_builds) in slave_info.items():
+ c['slaves'].append(BuildSlave(name, passwd, max_builds=max_builds))
# Add slaves to builders.
for builder in c['builders']:
name = builder.name
current_slaves = list(filter(None, builder.slavenames))
- for slavename, (passwd, builders) in slave_info.items():
+ for slavename, (passwd, builders, max_builds) in slave_info.items():
if name in builders:
current_slaves.append(slavename)
if not current_slaves: