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
=== modified file 'config.yaml'
--- config.yaml 2014-03-26 03:14:41 +0000
+++ config.yaml 2014-10-02 19:07:57 +0000
@@ -3,6 +3,14 @@
3 type: string3 type: string
4 default: git gcc make bzr4 default: git gcc make bzr
5 description: Tooling to deploy on jenkins slave node5 description: Tooling to deploy on jenkins slave node
6 master_url:
7 type: string
8 description: Jenkins master url
9 default: ""
10 slave_name:
11 type: string
12 description: Slave name on jenkins master to associate with node
13 default: ""
6 labels:14 labels:
7 type: string15 type: string
8 description: Jenkins labels to associate with jenkins slave node16 description: Jenkins labels to associate with jenkins slave node
917
=== added file 'files/99-adb.rules'
--- files/99-adb.rules 1970-01-01 00:00:00 +0000
+++ files/99-adb.rules 2014-10-02 19:07:57 +0000
@@ -0,0 +1,1 @@
1SUBSYSTEM=="usb", ATTR{idVendor}=="*", MODE="0777"
02
=== added directory 'files/lp'
=== added file 'files/lp/authentication.conf'
--- files/lp/authentication.conf 1970-01-01 00:00:00 +0000
+++ files/lp/authentication.conf 2014-10-02 19:07:57 +0000
@@ -0,0 +1,4 @@
1[Launchpad]
2host = .launchpad.net
3scheme = ssh
4user = ps-jenkins
05
=== added file 'files/lp/bazaar.conf'
--- files/lp/bazaar.conf 1970-01-01 00:00:00 +0000
+++ files/lp/bazaar.conf 2014-10-02 19:07:57 +0000
@@ -0,0 +1,3 @@
1[DEFAULT]
2email = ps-jenkins@lists.canonical.com
3launchpad_username = ps-jenkins
04
=== added file 'files/lp/config'
--- files/lp/config 1970-01-01 00:00:00 +0000
+++ files/lp/config 2014-10-02 19:07:57 +0000
@@ -0,0 +1,2 @@
1Host bazaar.launchpad.net
2 IdentityFile /var/lib/jenkins/.ssh/%h/%r/id_rsa
03
=== modified file 'hooks/install'
--- hooks/install 2014-05-15 18:46:43 +0000
+++ hooks/install 2014-10-02 19:07:57 +0000
@@ -2,27 +2,38 @@
22
3set -eux3set -eux
44
5slave_name=`config-get slave_name`
6master_url=`config-get master_url`
57
6# Install the slave if it is not installed already.8# Install the slave if it is not installed already.
7install_slave () {9install_slave () {
8 juju-log "Installing jenkins-slave..."10 juju-log "Installing jenkins-slave..."
9 if [[ ! -f /etc/init/jenkins-slave.conf ]]11 if [[ ! -f /etc/init/jenkins-slave-remote-${slave_name}.conf ]]
10 then12 then
11 if [[ $(apt-cache madison jenkins-slave) =~ .*jenkins-slave.* ]]13 # Install the same slave package as the precise Jenkins master.
12 then14 # Always install from the in-charm deb so that the modifications
13 apt-get -y install -qq jenkins-slave wget15 # are always applied to the same files.
14 else16 apt-get -y install -qq wget adduser default-jre-headless upstart-job
15 # This series doesn't provide a jenkins.17 dpkg -i files/jenkins-slave_*.deb
16 # Install the same slave package as the precise Jenkins master.
17 apt-get -y install -qq wget adduser default-jre-headless upstart-job
18 dpkg -i files/jenkins-slave_*.deb
19 fi
20 else18 else
21 juju-log "Jenkins-slave is already installed"19 juju-log "Jenkins-slave is already installed"
22 fi20 fi
23}21}
2422
2523
24modify_jenkins_settings () {
25 install /etc/init/jenkins-slave.conf /etc/init/jenkins-slave-remote-${slave_name}.conf
26 sed -i -e "/stop on/arespawn\nrespawn limit 10 5" \
27 -e "s!jenkins-slave!jenkins-slave-remote-${slave_name}!g" \
28 /etc/init/jenkins-slave-remote-${slave_name}.conf
29 install /etc/default/jenkins-slave /etc/default/jenkins-slave-remote-${slave_name}
30 sed -i -e "s!^JENKINS_HOSTNAME.*!JENKINS_HOSTNAME=${slave_name}!" \
31 -e "s!^#*JENKINS_URL.*!JENKINS_URL=${master_url}!" \
32 -e "s!jenkins-slave!jenkins-slave-remote-${slave_name}!" \
33 /etc/default/jenkins-slave-remote-${slave_name}
34}
35
36
26# Install extra packages needed by the slave.37# Install extra packages needed by the slave.
27install_tools () {38install_tools () {
28 juju-log "Installing tools..."39 juju-log "Installing tools..."
@@ -48,8 +59,17 @@
48 fi59 fi
49}60}
5061
62# Always refresh the apt db before installing any packages
63# Use multiple attempts to avoid transient hash mismatch errors
64apt-get update || apt-get update || apt-get update
5165
66# For config-changed, we want to ensure slave gets stopped and restarted
67# FIXME: 20140926 fginther - check if the upstart job is running first
68# https://app.asana.com/0/15652576021427/16759381549805
69hooks/stop || true
52install_slave70install_slave
71modify_jenkins_settings
53install_tools72install_tools
54install_extra_hooks73install_extra_hooks
74hooks/start
55exit 075exit 0
5676
=== added file 'hooks/install.d/0000-init.sh'
--- hooks/install.d/0000-init.sh 1970-01-01 00:00:00 +0000
+++ hooks/install.d/0000-init.sh 2014-10-02 19:07:57 +0000
@@ -0,0 +1,10 @@
1#!/bin/bash
2set -ex
3
4host_ip=`unit-get public-address`
5host_name=`hostname`
6
7# This resolves the problem of the unit not being able to resolve itself.
8if ! grep $host_name /etc/hosts; then
9 echo "$host_ip $host_name" >> /etc/hosts
10fi
011
=== added file 'hooks/install.d/3000-ci-tools.sh'
--- hooks/install.d/3000-ci-tools.sh 1970-01-01 00:00:00 +0000
+++ hooks/install.d/3000-ci-tools.sh 2014-10-02 19:07:57 +0000
@@ -0,0 +1,31 @@
1#!/bin/bash
2set -ex
3
4#Install tools needed for working with devices
5add-apt-repository ppa:phablet-team/tools < /dev/null
6add-apt-repository ppa:utah/stable < /dev/null
7
8apt-get update || apt-get update || apt-get update
9apt-get install -y --assume-yes phablet-tools ubuntu-device-flash utah \
10 autopkgtest bzr-builder subunit
11
12#Update the udev rules needed for adb devices
13cp files/99-adb.rules /etc/udev/rules.d
14udevadm control --reload-rules
15udevadm trigger
16
17#FIXME: 20140926 plars - find a better place for this
18# Existing tests assume /home/ubuntu/magners-wifi
19#https://app.asana.com/0/8312808705920/16730142900572
20cp files/secrets/wifi.conf /home/ubuntu/magners-wifi
21
22#Add jenkins to the utah group so that we can run utah tests without sudo
23addgroup jenkins utah
24
25#Setup sudo permissions for the jenkins user
26#FIXME: 20140926 plars - remove the need for this
27#https://app.asana.com/0/8312808705920/16730142900575
28if [ ! -f /etc/sudoers.d/jenkins ] ||
29 ! grep -q jenkins /etc/sudoers.d/jenkins; then
30 echo "jenkins ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
31fi
032
=== added file 'hooks/install.d/4000-lp-keys.sh'
--- hooks/install.d/4000-lp-keys.sh 1970-01-01 00:00:00 +0000
+++ hooks/install.d/4000-lp-keys.sh 2014-10-02 19:07:57 +0000
@@ -0,0 +1,19 @@
1#!/bin/bash
2set -ex
3
4install --owner=jenkins --group=jenkins -d \
5 /var/lib/jenkins/.ssh/bazaar.launchpad.net/ps-jenkins \
6 /var/lib/jenkins/.bazaar
7
8install --owner=jenkins --group=jenkins --mode=600 \
9 files/secrets/id_rsa \
10 /var/lib/jenkins/.ssh/bazaar.launchpad.net/ps-jenkins/
11install --owner=jenkins --group=jenkins \
12 files/lp/config files/secrets/known_hosts \
13 /var/lib/jenkins/.ssh/
14install --owner=jenkins --group=jenkins \
15 files/lp/authentication.conf files/lp/bazaar.conf \
16 /var/lib/jenkins/.bazaar
17install --owner=jenkins --group=jenkins \
18 files/secrets/.launchpad.credentials \
19 /var/lib/jenkins
020
=== modified file 'hooks/start'
--- hooks/start 2011-08-02 08:53:54 +0000
+++ hooks/start 2014-10-02 19:07:57 +0000
@@ -1,3 +1,5 @@
1#!/bin/bash1#!/bin/bash
22
3start jenkins-slave || true3slave_name=`config-get slave_name`
4
5start jenkins-slave-remote-${slave_name} || true
46
=== modified file 'hooks/stop'
--- hooks/stop 2011-08-02 08:53:54 +0000
+++ hooks/stop 2014-10-02 19:07:57 +0000
@@ -1,3 +1,5 @@
1#!/bin/bash1#!/bin/bash
22
3stop jenkins-slave3slave_name=`config-get slave_name`
4
5stop jenkins-slave-remote-${slave_name}
46
=== modified file 'metadata.yaml'
--- metadata.yaml 2014-05-15 16:22:53 +0000
+++ metadata.yaml 2014-10-02 19:07:57 +0000
@@ -1,14 +1,15 @@
1name: jenkins-slave1name: jenkins-remote-slave
2maintainer: James Page <james.page@ubuntu.com>2maintainer: Ubuntu Engineering CI Team <canonical-ci-engineering@lists.launchpad.net>
3summary: Jenkins CI Slave3summary: Jenkins CI Remote Slave
4description: |4description: |
5 Jenkins is a Continous Integration server supporting5 Jenkins is a Continous Integration server supporting
6 flexible continous integration and deployment methodologies6 flexible continous integration and deployment methodologies
7 and more.7 and more.
8 .8 .
9 This charm provides support for jenkins slaves9 This charm provides support for remote jenkins slaves connected to an
10 existing jenkins master.
10categories:11categories:
11 - applications12 - applications
12provides:13provides:
13 slave:14 slave:
14 interface: jenkins-slave15 interface: jenkins-remote-slave

Subscribers

People subscribed via source and target branches