Merge lp:~lutostag/charms/trusty/jenkins/jenkins+executor+remote-deb+plugins-move into lp:charms/trusty/jenkins

Proposed by Greg Lutostanski
Status: Merged
Merged at revision: 37
Proposed branch: lp:~lutostag/charms/trusty/jenkins/jenkins+executor+remote-deb+plugins-move
Merge into: lp:charms/trusty/jenkins
Diff against target: 136 lines (+36/-10)
4 files modified
config.yaml (+7/-1)
hooks/jenkins_hooks.py (+7/-3)
hooks/jenkins_utils.py (+21/-6)
templates/jenkins-config.xml (+1/-0)
To merge this branch: bzr merge lp:~lutostag/charms/trusty/jenkins/jenkins+executor+remote-deb+plugins-move
Reviewer Review Type Date Requested Status
Adam Israel (community) Approve
Review Queue (community) automated testing Approve
Ryan Beisner (community) Needs Information
Review via email: mp+280974@code.launchpad.net

Description of the change

Use a fully specified plugins-site -- don't change plugins-url to */latest/, just have it use the url directly, and change the default to take care of this.

Allow installing from remote deb link -- means you can change which version of jenkins you are using without bundling or having external net access for the ci-jenkins deb repos.

Allow setting number of executors on master explicitly with a config option.

To post a comment you must log in.
Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/1867/

review: Needs Fixing (automated testing)
Revision history for this message
Review Queue (review-queue) wrote :

The results (PASS) are in and available here: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/1847/

review: Approve (automated testing)
Revision history for this message
Ryan Beisner (1chb1n) wrote :

@lutostag

Thanks for you work on this! Everything seems pretty sane to me. The only holdback I have, is that slaves also have executors, and it may be misleading to have a charm config option named 'executors' which is pinned to just the master. Later, someone may want a knob to control the executors on slaves, independent from the master executor setting (ex. I know my test lab has differing quantities of executors on the master than on the slaves).

Perhaps "master-executors" for the charm config option name? That leaves room for slave-executors or something along those lines.

review: Needs Information
38. By Greg Lutostanski

config option name change executors->master-executors

Revision history for this message
Greg Lutostanski (lutostag) wrote :

Agreed on name change, thanks for the review.

39. By Greg Lutostanski

fix because jinja doesnt like "-" in variable names

Revision history for this message
Review Queue (review-queue) wrote :

This item has failed automated testing! Results available here http://juju-ci.vapour.ws:8080/job/charm-bundle-test-lxc/2174/

review: Needs Fixing (automated testing)
Revision history for this message
Review Queue (review-queue) wrote :

The results (PASS) are in and available here: http://juju-ci.vapour.ws:8080/job/charm-bundle-test-aws/2155/

review: Approve (automated testing)
Revision history for this message
Adam Israel (aisrael) wrote :

Hi Greg,

Thanks for your work on this patch so far! There are a few minor concerns, like proxy access in certain network configurations and payload verification (i.e., checksums) but jenkins isn't currently publishing an sha1 to compare against. Neither of those are immediately solvable, and not enough to hold this back.

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-11-11 23:32:08 +0000
3+++ config.yaml 2016-01-12 17:52:04 +0000
4@@ -14,6 +14,7 @@
5 manually copied over to the charm files/ dir before deployment
6 and named jenkins.deb. It can be downloaded from
7 http://pkg.jenkins-ci.org/debian/
8+ - http(s)://...: http(s) link to a retrievable jenkins deb
9 username:
10 type: string
11 default: admin
12@@ -30,7 +31,7 @@
13 description: Space separated list of plugins to install
14 plugins-site:
15 type: string
16- default: "https://updates.jenkins-ci.org/"
17+ default: "https://updates.jenkins-ci.org/latest/"
18 description: Site to download plugin .hpi files from.
19 plugins-check-certificate:
20 type: string
21@@ -42,3 +43,8 @@
22 description: |
23 Set this to yes to remove any plugins not listed in plugins
24 from the installation.
25+ master-executors:
26+ type: int
27+ default: 1
28+ description: |
29+ Number of executors to configure for jenkins master.
30
31=== modified file 'hooks/jenkins_hooks.py'
32--- hooks/jenkins_hooks.py 2015-11-17 21:39:23 +0000
33+++ hooks/jenkins_hooks.py 2016-01-12 17:52:04 +0000
34@@ -32,6 +32,7 @@
35 service_stop,
36 )
37 from charmhelpers.payload.execd import execd_preinstall
38+from charmhelpers.core.templating import render
39 from jenkins_utils import (
40 JENKINS_HOME,
41 JENKINS_USERS,
42@@ -41,6 +42,7 @@
43 get_jenkins_password,
44 setup_source,
45 install_from_bundle,
46+ install_from_remote_deb,
47 install_jenkins_plugins,
48 )
49
50@@ -52,6 +54,8 @@
51 execd_preinstall('hooks/install.d')
52 if config('release') == 'bundle':
53 install_from_bundle()
54+ elif config('release').startswith('http'):
55+ install_from_remote_deb(config('release'))
56 else:
57 # Only setup the source if jenkins is not already installed i.e. makes
58 # the config 'release' immutable so you can't change source once
59@@ -122,10 +126,10 @@
60 if not os.path.exists(jenkins_bootstrap_flag):
61 log("Bootstrapping secure initial configuration in Jenkins.",
62 level=DEBUG)
63- src = os.path.join(TEMPLATES_DIR, 'jenkins-config.xml')
64 dst = os.path.join(JENKINS_HOME, 'config.xml')
65- shutil.copy(src, dst)
66- os.chown(dst, jenkins_uid, nogroup_gid)
67+ context = {'master_executors': config('master-executors')}
68+ render('jenkins-config.xml', dst, context, owner='jenkins',
69+ group='nogroup')
70 # Touch
71 with open(jenkins_bootstrap_flag, 'w'):
72 pass
73
74=== modified file 'hooks/jenkins_utils.py'
75--- hooks/jenkins_utils.py 2015-11-11 23:32:08 +0000
76+++ hooks/jenkins_utils.py 2016-01-12 17:52:04 +0000
77@@ -62,6 +62,15 @@
78 log("Node '%s' does not exist - not deleting" % (host), level=INFO)
79
80
81+def install_local_deb(filename):
82+ """Install the given local jenkins deb"""
83+ # Install jenkins deps.
84+ apt_install(['daemon', 'adduser', 'psmisc', 'default-jre'], fatal=True)
85+ # Run dpkg to install bundled deb.
86+ env = os.environ.copy()
87+ subprocess.call(['dpkg', '-i', filename], env=env)
88+
89+
90 def install_from_bundle():
91 """Install Jenkins from bundled package."""
92 # Check bundled package exists.
93@@ -70,11 +79,17 @@
94 errmsg = "'%s' doesn't exist. No package bundled." % (bundle_path)
95 raise Exception(errmsg)
96 log('Installing from bundled Jenkins package: %s' % bundle_path)
97- # Install bundle deps.
98- apt_install(['daemon', 'adduser', 'psmisc', 'default-jre'], fatal=True)
99- # Run dpkg to install bundled deb.
100- env = os.environ.copy()
101- subprocess.call(['dpkg', '-i', bundle_path], env=env)
102+ install_local_deb(bundle_path)
103+
104+
105+def install_from_remote_deb(link):
106+ """Install Jenkins from http(s) deb file."""
107+ log('Getting remote jenkins package: %s' % link)
108+ tempdir = tempfile.mkdtemp()
109+ target = os.path.join(tempdir, 'jenkins.deb')
110+ subprocess.check_call(['wget', '-q', '-O', target, link])
111+ install_local_deb(target)
112+ shutil.rmtree(tempdir)
113
114
115 def setup_source(release):
116@@ -158,7 +173,7 @@
117
118 for plugin in plugins:
119 plugin_filename = "%s.hpi" % (plugin)
120- url = os.path.join(plugins_site, 'latest', plugin_filename)
121+ url = os.path.join(plugins_site, plugin_filename)
122 plugin_path = os.path.join(JENKINS_PLUGINS, plugin_filename)
123 if not os.path.isfile(plugin_path):
124 log("Installing plugin %s" % (plugin_filename), level=DEBUG)
125
126=== modified file 'templates/jenkins-config.xml'
127--- templates/jenkins-config.xml 2011-09-22 14:46:56 +0000
128+++ templates/jenkins-config.xml 2016-01-12 17:52:04 +0000
129@@ -1,6 +1,7 @@
130 <?xml version='1.0' encoding='UTF-8'?>
131 <hudson>
132 <useSecurity>true</useSecurity>
133+ <numExecutors>{{master_executors}}</numExecutors>
134 <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy"/>
135 <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
136 <disableSignup>true</disableSignup>

Subscribers

People subscribed via source and target branches

to all changes: