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
=== modified file 'config.yaml'
--- config.yaml 2015-11-11 23:32:08 +0000
+++ config.yaml 2016-01-12 17:52:04 +0000
@@ -14,6 +14,7 @@
14 manually copied over to the charm files/ dir before deployment14 manually copied over to the charm files/ dir before deployment
15 and named jenkins.deb. It can be downloaded from15 and named jenkins.deb. It can be downloaded from
16 http://pkg.jenkins-ci.org/debian/16 http://pkg.jenkins-ci.org/debian/
17 - http(s)://...: http(s) link to a retrievable jenkins deb
17 username:18 username:
18 type: string19 type: string
19 default: admin20 default: admin
@@ -30,7 +31,7 @@
30 description: Space separated list of plugins to install31 description: Space separated list of plugins to install
31 plugins-site:32 plugins-site:
32 type: string33 type: string
33 default: "https://updates.jenkins-ci.org/"34 default: "https://updates.jenkins-ci.org/latest/"
34 description: Site to download plugin .hpi files from.35 description: Site to download plugin .hpi files from.
35 plugins-check-certificate:36 plugins-check-certificate:
36 type: string37 type: string
@@ -42,3 +43,8 @@
42 description: |43 description: |
43 Set this to yes to remove any plugins not listed in plugins44 Set this to yes to remove any plugins not listed in plugins
44 from the installation.45 from the installation.
46 master-executors:
47 type: int
48 default: 1
49 description: |
50 Number of executors to configure for jenkins master.
4551
=== modified file 'hooks/jenkins_hooks.py'
--- hooks/jenkins_hooks.py 2015-11-17 21:39:23 +0000
+++ hooks/jenkins_hooks.py 2016-01-12 17:52:04 +0000
@@ -32,6 +32,7 @@
32 service_stop,32 service_stop,
33)33)
34from charmhelpers.payload.execd import execd_preinstall34from charmhelpers.payload.execd import execd_preinstall
35from charmhelpers.core.templating import render
35from jenkins_utils import (36from jenkins_utils import (
36 JENKINS_HOME,37 JENKINS_HOME,
37 JENKINS_USERS,38 JENKINS_USERS,
@@ -41,6 +42,7 @@
41 get_jenkins_password,42 get_jenkins_password,
42 setup_source,43 setup_source,
43 install_from_bundle,44 install_from_bundle,
45 install_from_remote_deb,
44 install_jenkins_plugins,46 install_jenkins_plugins,
45)47)
4648
@@ -52,6 +54,8 @@
52 execd_preinstall('hooks/install.d')54 execd_preinstall('hooks/install.d')
53 if config('release') == 'bundle':55 if config('release') == 'bundle':
54 install_from_bundle()56 install_from_bundle()
57 elif config('release').startswith('http'):
58 install_from_remote_deb(config('release'))
55 else:59 else:
56 # Only setup the source if jenkins is not already installed i.e. makes60 # Only setup the source if jenkins is not already installed i.e. makes
57 # the config 'release' immutable so you can't change source once61 # the config 'release' immutable so you can't change source once
@@ -122,10 +126,10 @@
122 if not os.path.exists(jenkins_bootstrap_flag):126 if not os.path.exists(jenkins_bootstrap_flag):
123 log("Bootstrapping secure initial configuration in Jenkins.",127 log("Bootstrapping secure initial configuration in Jenkins.",
124 level=DEBUG)128 level=DEBUG)
125 src = os.path.join(TEMPLATES_DIR, 'jenkins-config.xml')
126 dst = os.path.join(JENKINS_HOME, 'config.xml')129 dst = os.path.join(JENKINS_HOME, 'config.xml')
127 shutil.copy(src, dst)130 context = {'master_executors': config('master-executors')}
128 os.chown(dst, jenkins_uid, nogroup_gid)131 render('jenkins-config.xml', dst, context, owner='jenkins',
132 group='nogroup')
129 # Touch133 # Touch
130 with open(jenkins_bootstrap_flag, 'w'):134 with open(jenkins_bootstrap_flag, 'w'):
131 pass135 pass
132136
=== modified file 'hooks/jenkins_utils.py'
--- hooks/jenkins_utils.py 2015-11-11 23:32:08 +0000
+++ hooks/jenkins_utils.py 2016-01-12 17:52:04 +0000
@@ -62,6 +62,15 @@
62 log("Node '%s' does not exist - not deleting" % (host), level=INFO)62 log("Node '%s' does not exist - not deleting" % (host), level=INFO)
6363
6464
65def install_local_deb(filename):
66 """Install the given local jenkins deb"""
67 # Install jenkins deps.
68 apt_install(['daemon', 'adduser', 'psmisc', 'default-jre'], fatal=True)
69 # Run dpkg to install bundled deb.
70 env = os.environ.copy()
71 subprocess.call(['dpkg', '-i', filename], env=env)
72
73
65def install_from_bundle():74def install_from_bundle():
66 """Install Jenkins from bundled package."""75 """Install Jenkins from bundled package."""
67 # Check bundled package exists.76 # Check bundled package exists.
@@ -70,11 +79,17 @@
70 errmsg = "'%s' doesn't exist. No package bundled." % (bundle_path)79 errmsg = "'%s' doesn't exist. No package bundled." % (bundle_path)
71 raise Exception(errmsg)80 raise Exception(errmsg)
72 log('Installing from bundled Jenkins package: %s' % bundle_path)81 log('Installing from bundled Jenkins package: %s' % bundle_path)
73 # Install bundle deps.82 install_local_deb(bundle_path)
74 apt_install(['daemon', 'adduser', 'psmisc', 'default-jre'], fatal=True)83
75 # Run dpkg to install bundled deb.84
76 env = os.environ.copy()85def install_from_remote_deb(link):
77 subprocess.call(['dpkg', '-i', bundle_path], env=env)86 """Install Jenkins from http(s) deb file."""
87 log('Getting remote jenkins package: %s' % link)
88 tempdir = tempfile.mkdtemp()
89 target = os.path.join(tempdir, 'jenkins.deb')
90 subprocess.check_call(['wget', '-q', '-O', target, link])
91 install_local_deb(target)
92 shutil.rmtree(tempdir)
7893
7994
80def setup_source(release):95def setup_source(release):
@@ -158,7 +173,7 @@
158173
159 for plugin in plugins:174 for plugin in plugins:
160 plugin_filename = "%s.hpi" % (plugin)175 plugin_filename = "%s.hpi" % (plugin)
161 url = os.path.join(plugins_site, 'latest', plugin_filename)176 url = os.path.join(plugins_site, plugin_filename)
162 plugin_path = os.path.join(JENKINS_PLUGINS, plugin_filename)177 plugin_path = os.path.join(JENKINS_PLUGINS, plugin_filename)
163 if not os.path.isfile(plugin_path):178 if not os.path.isfile(plugin_path):
164 log("Installing plugin %s" % (plugin_filename), level=DEBUG)179 log("Installing plugin %s" % (plugin_filename), level=DEBUG)
165180
=== modified file 'templates/jenkins-config.xml'
--- templates/jenkins-config.xml 2011-09-22 14:46:56 +0000
+++ templates/jenkins-config.xml 2016-01-12 17:52:04 +0000
@@ -1,6 +1,7 @@
1<?xml version='1.0' encoding='UTF-8'?>1<?xml version='1.0' encoding='UTF-8'?>
2<hudson>2<hudson>
3 <useSecurity>true</useSecurity>3 <useSecurity>true</useSecurity>
4 <numExecutors>{{master_executors}}</numExecutors>
4 <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy"/>5 <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy"/>
5 <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">6 <securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
6 <disableSignup>true</disableSignup>7 <disableSignup>true</disableSignup>

Subscribers

People subscribed via source and target branches

to all changes: