Merge lp:~fginther/ubuntu-ci-services-itself/lander-address-and-executor-fixes into lp:ubuntu-ci-services-itself

Proposed by Francis Ginther
Status: Merged
Approved by: Chris Johnston
Approved revision: 287
Merged at revision: 292
Proposed branch: lp:~fginther/ubuntu-ci-services-itself/lander-address-and-executor-fixes
Merge into: lp:ubuntu-ci-services-itself
Diff against target: 67 lines (+25/-0)
2 files modified
charms/precise/lander-jenkins/config.yaml (+4/-0)
charms/precise/lander-jenkins/hooks/hooks.py (+21/-0)
To merge this branch: bzr merge lp:~fginther/ubuntu-ci-services-itself/lander-address-and-executor-fixes
Reviewer Review Type Date Requested Status
Chris Johnston (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+208867@code.launchpad.net

Commit message

If multiple private addresses are present for the jenkins instance, take the first one. Provide config option for specifying number of jenkins executors.

Description of the change

If multiple private addresses are present for the jenkins instance, take the first one. Provide config option for specifying number of jenkins executors.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:287
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/253/
Executed test runs:

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/uci-engine-ci/253/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Johnston (cjohnston) :
review: Approve
Revision history for this message
Andy Doan (doanac) wrote :

yeah!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charms/precise/lander-jenkins/config.yaml'
--- charms/precise/lander-jenkins/config.yaml 2014-02-13 21:04:50 +0000
+++ charms/precise/lander-jenkins/config.yaml 2014-02-28 18:58:15 +0000
@@ -27,6 +27,10 @@
27 type: string27 type: string
28 default: ""28 default: ""
29 description: Launchpad login id of lander bot29 description: Launchpad login id of lander bot
30 num_executors:
31 type: int
32 default: 5
33 description: Number of executions slots for jenkins master.
30 branch:34 branch:
31 type: string35 type: string
32 description: "BZR branch the service lives in"36 description: "BZR branch the service lives in"
3337
=== modified file 'charms/precise/lander-jenkins/hooks/hooks.py'
--- charms/precise/lander-jenkins/hooks/hooks.py 2014-02-13 21:04:50 +0000
+++ charms/precise/lander-jenkins/hooks/hooks.py 2014-02-28 18:58:15 +0000
@@ -19,6 +19,7 @@
19JENKINS_HOME = '/var/lib/jenkins'19JENKINS_HOME = '/var/lib/jenkins'
20JENKINS_USER = 'jenkins'20JENKINS_USER = 'jenkins'
21JENKINS_GROUP = 'nogroup'21JENKINS_GROUP = 'nogroup'
22NUM_EXECUTORS_LINE = ' <numExecutors>{}</numExecutors>\n'
2223
2324
24def juju_info(msg, level='INFO'):25def juju_info(msg, level='INFO'):
@@ -233,6 +234,20 @@
233 os.fsync(f.fileno())234 os.fsync(f.fileno())
234235
235236
237def update_jenkins_master(config):
238 juju_info('Updating master jenkins.')
239 jenkins_master_config = os.path.join(JENKINS_HOME, 'config.xml')
240 num_executors = config.get('num_executors', None)
241 if num_executors and os.path.exists(jenkins_master_config):
242 with open(jenkins_master_config) as in_file:
243 contents = in_file.readlines()
244 with open(jenkins_master_config, 'w') as out_file:
245 for line in contents:
246 out_file.write(line)
247 if line.startswith('<hudson>'):
248 out_file.write(NUM_EXECUTORS_LINE.format(num_executors))
249
250
236def restart_jenkins(config):251def restart_jenkins(config):
237 juju_info('Restarting jenkins.')252 juju_info('Restarting jenkins.')
238 core.host.service_stop('jenkins')253 core.host.service_stop('jenkins')
@@ -255,6 +270,7 @@
255 setup_plugins(config)270 setup_plugins(config)
256 create_unit_config(config)271 create_unit_config(config)
257 create_upstart(config)272 create_upstart(config)
273 update_jenkins_master(config)
258 restart_jenkins(config)274 restart_jenkins(config)
259 restart_upstart(config)275 restart_upstart(config)
260276
@@ -262,6 +278,11 @@
262def lander_jenkins_relation_joined(config):278def lander_jenkins_relation_joined(config):
263 juju_info("Config: %s" % config)279 juju_info("Config: %s" % config)
264 hostname = subprocess.check_output(['unit-get', 'private-address']).strip()280 hostname = subprocess.check_output(['unit-get', 'private-address']).strip()
281 if ',' in hostname:
282 # We can't have multiple hostnames, take the first one
283 juju_info('Found too many private-addresses {}'.format(hostname))
284 hostname = hostname.split(',')[0]
285 juju_info('Taking first private-address: {}'.format(hostname))
265 lander_config = {286 lander_config = {
266 'lander_username': config['bot_username'],287 'lander_username': config['bot_username'],
267 'lander_password': config['bot_password'],288 'lander_password': config['bot_password'],

Subscribers

People subscribed via source and target branches