Merge lp:~fginther/charms/trusty/jenkins-remote-slave/jenkins-phablet-slave into lp:~canonical-ci-engineering/charms/trusty/jenkins-remote-slave/trunk

Proposed by Francis Ginther
Status: Merged
Approved by: Francis Ginther
Approved revision: 32
Merged at revision: 14
Proposed branch: lp:~fginther/charms/trusty/jenkins-remote-slave/jenkins-phablet-slave
Merge into: lp:~canonical-ci-engineering/charms/trusty/jenkins-remote-slave/trunk
Diff against target: 242 lines (+120/-17)
12 files modified
config.yaml (+8/-0)
files/99-adb.rules (+1/-0)
files/lp/authentication.conf (+4/-0)
files/lp/bazaar.conf (+3/-0)
files/lp/config (+2/-0)
hooks/install (+30/-10)
hooks/install.d/0000-init.sh (+10/-0)
hooks/install.d/3000-ci-tools.sh (+31/-0)
hooks/install.d/4000-lp-keys.sh (+19/-0)
hooks/start (+3/-1)
hooks/stop (+3/-1)
metadata.yaml (+6/-5)
To merge this branch: bzr merge lp:~fginther/charms/trusty/jenkins-remote-slave/jenkins-phablet-slave
Reviewer Review Type Date Requested Status
Paul Larson Approve
Evan (community) Needs Fixing
Vincent Ladeuil (community) Approve
Review via email: mp+235872@code.launchpad.net

Commit message

Allow specification of a jenkins master and slave name to connect to instead of a master set via a relationship. Add provisioning scripts to setup an adb host and keys for operation with the ci-teams existing jobs.

Description of the change

Allow specification of a jenkins master and slave name to connect to instead of a master set via a relationship. Add provisioning scripts to setup an adb host and keys for operation with the ci-teams existing jobs.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Nice job !

A few inline comments but no blockers, I think I don't quite understand the details of how it works (but I can't see anything that should break either ;).

review: Approve
Revision history for this message
Evan (ev) wrote :

Largely looks good, but I have a few concerns inline.

review: Needs Fixing
Revision history for this message
Evan (ev) wrote :

Also, we should convert this piece by piece to python with tests as we iterate on it. Not worth blocking this MP on that, but we should address it soon.

Revision history for this message
Paul Larson (pwlars) wrote :

Responded to a few of these for now

Revision history for this message
Evan (ev) wrote :

Comments inline.

Revision history for this message
Francis Ginther (fginther) wrote :

To address the multiple comments on "files/jenkins-slave/jenkins-slave-remote". This file is a copy of the one supplied by the jenkins-slave package. The only values we actually care about are: NAME,
JENKINS_HOSTNAME and JENKINS_URL. An improved sed command would allow us to use the one supplied by the package itself and not have to supply the copy.

files/jenkins-slave/jenkins-slave-remote.conf is also supplied by the jenkins-slave package, but its version is missing the start/stop/respawn portion.

I'll attempt to respond the comments for changes, but may have to iterate with plars on a few. Will make note if this is the case.

Revision history for this message
Paul Larson (pwlars) wrote :

A few responses below.

Francis, since this is your branch, I can't modify it. If it would be easier, I'm happy to have placeholders for some of these comments and merge it pretty much as is, then we can more easily collaborate on hitting the FIXMEs in parallel.

review: Approve
Revision history for this message
Evan (ev) :
Revision history for this message
Paul Larson (pwlars) wrote :

Please pull lp:~pwlars/charms/trusty/jenkins-slave/phablet-slave-fixups rev 24 - this moves the install.d hook for jenkins slaves into the main install hook and recycles the existing template upstart files rather than adding our own copies as discussed.

Revision history for this message
Paul Larson (pwlars) wrote :

Also added lp:~pwlars/charms/trusty/jenkins-slave/phablet-slave-fixups rev 25-27 (see comments below for what they are related to). I'll also be adding a 28 in just a moment to fix something I realized is wrong with how I did the install conversion for rev 24. minor fix - will be in rev 28 of my branch.

24. By Francis Ginther

Update metadata.yaml as this charm is distinct from jenkins-slave.

25. By Francis Ginther

Convert 4000-lp-keys.sh to use 'install'.

26. By Francis Ginther

Drop the extra jenkins-slave-remote files and just modify those supplied by the jenkins-slave package. Add fixmes and task links for future updates to the wifi.conf setup and removing jenkins sudo accesss.

27. By Francis Ginther

Add subunit dependency to 3000-ci-tools.sh.

28. By Francis Ginther

Add FIXME comment for ignoring failures on stop, annotate other FIXME comments and explain the purpose of 0000-init.sh.

29. By Francis Ginther

Check and modify the correct sudoers file.

30. By Francis Ginther

Always install jenkins-slave from the in-charm deb package.

31. By Francis Ginther

Perform an apt-get update prior to install jenkins-slave packages.

Revision history for this message
Paul Larson (pwlars) wrote :

Seems to work ok here with one very minor fix. Please pull r30 from my branch

review: Approve
32. By Francis Ginther

Add jenkins to the utah group so that we can run utah tests without sudo and fix global replacement of 'jenkins-slave' in the upstart conf file.

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 2014-03-26 03:14:41 +0000
3+++ config.yaml 2014-10-02 19:07:57 +0000
4@@ -3,6 +3,14 @@
5 type: string
6 default: git gcc make bzr
7 description: Tooling to deploy on jenkins slave node
8+ master_url:
9+ type: string
10+ description: Jenkins master url
11+ default: ""
12+ slave_name:
13+ type: string
14+ description: Slave name on jenkins master to associate with node
15+ default: ""
16 labels:
17 type: string
18 description: Jenkins labels to associate with jenkins slave node
19
20=== added file 'files/99-adb.rules'
21--- files/99-adb.rules 1970-01-01 00:00:00 +0000
22+++ files/99-adb.rules 2014-10-02 19:07:57 +0000
23@@ -0,0 +1,1 @@
24+SUBSYSTEM=="usb", ATTR{idVendor}=="*", MODE="0777"
25
26=== added directory 'files/lp'
27=== added file 'files/lp/authentication.conf'
28--- files/lp/authentication.conf 1970-01-01 00:00:00 +0000
29+++ files/lp/authentication.conf 2014-10-02 19:07:57 +0000
30@@ -0,0 +1,4 @@
31+[Launchpad]
32+host = .launchpad.net
33+scheme = ssh
34+user = ps-jenkins
35
36=== added file 'files/lp/bazaar.conf'
37--- files/lp/bazaar.conf 1970-01-01 00:00:00 +0000
38+++ files/lp/bazaar.conf 2014-10-02 19:07:57 +0000
39@@ -0,0 +1,3 @@
40+[DEFAULT]
41+email = ps-jenkins@lists.canonical.com
42+launchpad_username = ps-jenkins
43
44=== added file 'files/lp/config'
45--- files/lp/config 1970-01-01 00:00:00 +0000
46+++ files/lp/config 2014-10-02 19:07:57 +0000
47@@ -0,0 +1,2 @@
48+Host bazaar.launchpad.net
49+ IdentityFile /var/lib/jenkins/.ssh/%h/%r/id_rsa
50
51=== modified file 'hooks/install'
52--- hooks/install 2014-05-15 18:46:43 +0000
53+++ hooks/install 2014-10-02 19:07:57 +0000
54@@ -2,27 +2,38 @@
55
56 set -eux
57
58+slave_name=`config-get slave_name`
59+master_url=`config-get master_url`
60
61 # Install the slave if it is not installed already.
62 install_slave () {
63 juju-log "Installing jenkins-slave..."
64- if [[ ! -f /etc/init/jenkins-slave.conf ]]
65+ if [[ ! -f /etc/init/jenkins-slave-remote-${slave_name}.conf ]]
66 then
67- if [[ $(apt-cache madison jenkins-slave) =~ .*jenkins-slave.* ]]
68- then
69- apt-get -y install -qq jenkins-slave wget
70- else
71- # This series doesn't provide a jenkins.
72- # Install the same slave package as the precise Jenkins master.
73- apt-get -y install -qq wget adduser default-jre-headless upstart-job
74- dpkg -i files/jenkins-slave_*.deb
75- fi
76+ # Install the same slave package as the precise Jenkins master.
77+ # Always install from the in-charm deb so that the modifications
78+ # are always applied to the same files.
79+ apt-get -y install -qq wget adduser default-jre-headless upstart-job
80+ dpkg -i files/jenkins-slave_*.deb
81 else
82 juju-log "Jenkins-slave is already installed"
83 fi
84 }
85
86
87+modify_jenkins_settings () {
88+ install /etc/init/jenkins-slave.conf /etc/init/jenkins-slave-remote-${slave_name}.conf
89+ sed -i -e "/stop on/arespawn\nrespawn limit 10 5" \
90+ -e "s!jenkins-slave!jenkins-slave-remote-${slave_name}!g" \
91+ /etc/init/jenkins-slave-remote-${slave_name}.conf
92+ install /etc/default/jenkins-slave /etc/default/jenkins-slave-remote-${slave_name}
93+ sed -i -e "s!^JENKINS_HOSTNAME.*!JENKINS_HOSTNAME=${slave_name}!" \
94+ -e "s!^#*JENKINS_URL.*!JENKINS_URL=${master_url}!" \
95+ -e "s!jenkins-slave!jenkins-slave-remote-${slave_name}!" \
96+ /etc/default/jenkins-slave-remote-${slave_name}
97+}
98+
99+
100 # Install extra packages needed by the slave.
101 install_tools () {
102 juju-log "Installing tools..."
103@@ -48,8 +59,17 @@
104 fi
105 }
106
107+# Always refresh the apt db before installing any packages
108+# Use multiple attempts to avoid transient hash mismatch errors
109+apt-get update || apt-get update || apt-get update
110
111+# For config-changed, we want to ensure slave gets stopped and restarted
112+# FIXME: 20140926 fginther - check if the upstart job is running first
113+# https://app.asana.com/0/15652576021427/16759381549805
114+hooks/stop || true
115 install_slave
116+modify_jenkins_settings
117 install_tools
118 install_extra_hooks
119+hooks/start
120 exit 0
121
122=== added file 'hooks/install.d/0000-init.sh'
123--- hooks/install.d/0000-init.sh 1970-01-01 00:00:00 +0000
124+++ hooks/install.d/0000-init.sh 2014-10-02 19:07:57 +0000
125@@ -0,0 +1,10 @@
126+#!/bin/bash
127+set -ex
128+
129+host_ip=`unit-get public-address`
130+host_name=`hostname`
131+
132+# This resolves the problem of the unit not being able to resolve itself.
133+if ! grep $host_name /etc/hosts; then
134+ echo "$host_ip $host_name" >> /etc/hosts
135+fi
136
137=== added file 'hooks/install.d/3000-ci-tools.sh'
138--- hooks/install.d/3000-ci-tools.sh 1970-01-01 00:00:00 +0000
139+++ hooks/install.d/3000-ci-tools.sh 2014-10-02 19:07:57 +0000
140@@ -0,0 +1,31 @@
141+#!/bin/bash
142+set -ex
143+
144+#Install tools needed for working with devices
145+add-apt-repository ppa:phablet-team/tools < /dev/null
146+add-apt-repository ppa:utah/stable < /dev/null
147+
148+apt-get update || apt-get update || apt-get update
149+apt-get install -y --assume-yes phablet-tools ubuntu-device-flash utah \
150+ autopkgtest bzr-builder subunit
151+
152+#Update the udev rules needed for adb devices
153+cp files/99-adb.rules /etc/udev/rules.d
154+udevadm control --reload-rules
155+udevadm trigger
156+
157+#FIXME: 20140926 plars - find a better place for this
158+# Existing tests assume /home/ubuntu/magners-wifi
159+#https://app.asana.com/0/8312808705920/16730142900572
160+cp files/secrets/wifi.conf /home/ubuntu/magners-wifi
161+
162+#Add jenkins to the utah group so that we can run utah tests without sudo
163+addgroup jenkins utah
164+
165+#Setup sudo permissions for the jenkins user
166+#FIXME: 20140926 plars - remove the need for this
167+#https://app.asana.com/0/8312808705920/16730142900575
168+if [ ! -f /etc/sudoers.d/jenkins ] ||
169+ ! grep -q jenkins /etc/sudoers.d/jenkins; then
170+ echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
171+fi
172
173=== added file 'hooks/install.d/4000-lp-keys.sh'
174--- hooks/install.d/4000-lp-keys.sh 1970-01-01 00:00:00 +0000
175+++ hooks/install.d/4000-lp-keys.sh 2014-10-02 19:07:57 +0000
176@@ -0,0 +1,19 @@
177+#!/bin/bash
178+set -ex
179+
180+install --owner=jenkins --group=jenkins -d \
181+ /var/lib/jenkins/.ssh/bazaar.launchpad.net/ps-jenkins \
182+ /var/lib/jenkins/.bazaar
183+
184+install --owner=jenkins --group=jenkins --mode=600 \
185+ files/secrets/id_rsa \
186+ /var/lib/jenkins/.ssh/bazaar.launchpad.net/ps-jenkins/
187+install --owner=jenkins --group=jenkins \
188+ files/lp/config files/secrets/known_hosts \
189+ /var/lib/jenkins/.ssh/
190+install --owner=jenkins --group=jenkins \
191+ files/lp/authentication.conf files/lp/bazaar.conf \
192+ /var/lib/jenkins/.bazaar
193+install --owner=jenkins --group=jenkins \
194+ files/secrets/.launchpad.credentials \
195+ /var/lib/jenkins
196
197=== modified file 'hooks/start'
198--- hooks/start 2011-08-02 08:53:54 +0000
199+++ hooks/start 2014-10-02 19:07:57 +0000
200@@ -1,3 +1,5 @@
201 #!/bin/bash
202
203-start jenkins-slave || true
204+slave_name=`config-get slave_name`
205+
206+start jenkins-slave-remote-${slave_name} || true
207
208=== modified file 'hooks/stop'
209--- hooks/stop 2011-08-02 08:53:54 +0000
210+++ hooks/stop 2014-10-02 19:07:57 +0000
211@@ -1,3 +1,5 @@
212 #!/bin/bash
213
214-stop jenkins-slave
215+slave_name=`config-get slave_name`
216+
217+stop jenkins-slave-remote-${slave_name}
218
219=== modified file 'metadata.yaml'
220--- metadata.yaml 2014-05-15 16:22:53 +0000
221+++ metadata.yaml 2014-10-02 19:07:57 +0000
222@@ -1,14 +1,15 @@
223-name: jenkins-slave
224-maintainer: James Page <james.page@ubuntu.com>
225-summary: Jenkins CI Slave
226+name: jenkins-remote-slave
227+maintainer: Ubuntu Engineering CI Team <canonical-ci-engineering@lists.launchpad.net>
228+summary: Jenkins CI Remote Slave
229 description: |
230 Jenkins is a Continous Integration server supporting
231 flexible continous integration and deployment methodologies
232 and more.
233 .
234- This charm provides support for jenkins slaves
235+ This charm provides support for remote jenkins slaves connected to an
236+ existing jenkins master.
237 categories:
238 - applications
239 provides:
240 slave:
241- interface: jenkins-slave
242+ interface: jenkins-remote-slave

Subscribers

People subscribed via source and target branches