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
1=== modified file 'charms/precise/lander-jenkins/config.yaml'
2--- charms/precise/lander-jenkins/config.yaml 2014-02-13 21:04:50 +0000
3+++ charms/precise/lander-jenkins/config.yaml 2014-02-28 18:58:15 +0000
4@@ -27,6 +27,10 @@
5 type: string
6 default: ""
7 description: Launchpad login id of lander bot
8+ num_executors:
9+ type: int
10+ default: 5
11+ description: Number of executions slots for jenkins master.
12 branch:
13 type: string
14 description: "BZR branch the service lives in"
15
16=== modified file 'charms/precise/lander-jenkins/hooks/hooks.py'
17--- charms/precise/lander-jenkins/hooks/hooks.py 2014-02-13 21:04:50 +0000
18+++ charms/precise/lander-jenkins/hooks/hooks.py 2014-02-28 18:58:15 +0000
19@@ -19,6 +19,7 @@
20 JENKINS_HOME = '/var/lib/jenkins'
21 JENKINS_USER = 'jenkins'
22 JENKINS_GROUP = 'nogroup'
23+NUM_EXECUTORS_LINE = ' <numExecutors>{}</numExecutors>\n'
24
25
26 def juju_info(msg, level='INFO'):
27@@ -233,6 +234,20 @@
28 os.fsync(f.fileno())
29
30
31+def update_jenkins_master(config):
32+ juju_info('Updating master jenkins.')
33+ jenkins_master_config = os.path.join(JENKINS_HOME, 'config.xml')
34+ num_executors = config.get('num_executors', None)
35+ if num_executors and os.path.exists(jenkins_master_config):
36+ with open(jenkins_master_config) as in_file:
37+ contents = in_file.readlines()
38+ with open(jenkins_master_config, 'w') as out_file:
39+ for line in contents:
40+ out_file.write(line)
41+ if line.startswith('<hudson>'):
42+ out_file.write(NUM_EXECUTORS_LINE.format(num_executors))
43+
44+
45 def restart_jenkins(config):
46 juju_info('Restarting jenkins.')
47 core.host.service_stop('jenkins')
48@@ -255,6 +270,7 @@
49 setup_plugins(config)
50 create_unit_config(config)
51 create_upstart(config)
52+ update_jenkins_master(config)
53 restart_jenkins(config)
54 restart_upstart(config)
55
56@@ -262,6 +278,11 @@
57 def lander_jenkins_relation_joined(config):
58 juju_info("Config: %s" % config)
59 hostname = subprocess.check_output(['unit-get', 'private-address']).strip()
60+ if ',' in hostname:
61+ # We can't have multiple hostnames, take the first one
62+ juju_info('Found too many private-addresses {}'.format(hostname))
63+ hostname = hostname.split(',')[0]
64+ juju_info('Taking first private-address: {}'.format(hostname))
65 lander_config = {
66 'lander_username': config['bot_username'],
67 'lander_password': config['bot_password'],

Subscribers

People subscribed via source and target branches