Merge lp:~gary/charms/oneiric/buildbot-slave/run-as-buildbot into lp:~yellow/charms/oneiric/buildbot-slave/trunk

Proposed by Gary Poster
Status: Merged
Merged at revision: 13
Proposed branch: lp:~gary/charms/oneiric/buildbot-slave/run-as-buildbot
Merge into: lp:~yellow/charms/oneiric/buildbot-slave/trunk
Diff against target: 107 lines (+38/-7)
3 files modified
config.setuplxc.yaml (+4/-2)
config.yaml (+1/-1)
hooks/install (+33/-4)
To merge this branch: bzr merge lp:~gary/charms/oneiric/buildbot-slave/run-as-buildbot
Reviewer Review Type Date Requested Status
Francesco Banconi Approve
Review via email: mp+92400@code.launchpad.net

Description of the change

These changes, along with those in https://code.launchpad.net/~gary/charms/oneiric/buildbot-master/run-as-buildbot/+merge/92399 , make the buildbot slave run as the buildbot user, and generally matches the Debian setup better.

To post a comment you must log in.
Revision history for this message
Gary Poster (gary) wrote :

(As from the buildbot-master branch...)

The su contextmanager has an issue: the euid and egid are not set back properly when there is an error in the with block, for some reason. This can cause some problems: for some reason the juju log command hangs when the buildbot user tries to use it. Benji and I took a quick look at it and did not see a reason why they would do this. Perhaps it takes a moment to propagate?

I have not yet run the existing tests. I will do this before landing, resolving any issues. That said, this will bring up a master and slave for lpbuildbot, and at least check out the branch. Subsequently there's an error within Twisted/Buildbot itself, but it's on the right track.

Revision history for this message
Francesco Banconi (frankban) wrote :

Thank you Gary for this nice branch.

100 + # This is naive; we can make it more sophisticated (e.g., allowing
101 + # escaping dollar signs) if we discover we need it. For now,
102 + # simplicity wins.
103 + replaced_args = args.replace('$INSTALLDIR', buildbot_dir)

We could also do something like::

    formatted_args = args.format(**config)

And then, in the config file::

    script-args: "-u buildbot -e <email address hidden> -f 'Launchpad PQM' {installdir}"

It's as naive as your version, but maybe a little more generic?

60 - command('hg', 'clone', source, target)
61 + run('hg', 'clone', source, target)

Thank you for fixing all the script retrieval functions.
I have to make a note to myself: command helper returns a function!

Also thanks for your change on how the su context manager retrieves the user home directory:
please see the comment on the master MP for a suggestion on how to fix the exceptions problem too.

I've seen now buildslave is created in the install hook (great IMHO), but the same code is still present in config-changed: this could generate errors (buildslave created twice?), and requires further investigation.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.setuplxc.yaml'
2--- config.setuplxc.yaml 2012-02-06 21:11:38 +0000
3+++ config.setuplxc.yaml 2012-02-10 01:16:25 +0000
4@@ -1,8 +1,10 @@
5 buildbot-slave:
6 builders: lucid_lp,lucid_db_lp
7 script-retrieval-method: bzr_cat
8- script-url: "http://bazaar.launchpad.net/~gmb/launchpad/neuter-setuplxc/utilities/setuplxc.py"
9+ script-url: "http://bazaar.launchpad.net/~gary/launchpad/setuplxc/utilities/setuplxc.py"
10 script-path: setuplxc.py
11- script-args: "-u launchpad-pqm -e launchpad-pqm@canonical.com -f 'Launchpad PQM' /home/launchpad-pqm/launchpad/"
12+ # The buildbot user's home directory is /var/lib/buildout.
13+ # The LP dependencies will be in /var/lib/buildout/dependencies.
14+ script-args: "-u buildbot -e launchpad-pqm@canonical.com -f 'Launchpad PQM' $INSTALLDIR"
15 extra-repository: deb http://us.archive.ubuntu.com/ubuntu/ lucid main universe
16 buildbot-pkg: buildbot/lucid
17
18=== modified file 'config.yaml'
19--- config.yaml 2012-02-06 21:11:38 +0000
20+++ config.yaml 2012-02-10 01:16:25 +0000
21@@ -40,4 +40,4 @@
22 description: |
23 The directory where the Buildbot slave will be installed.
24 type: string
25- default: /tmp/buildslave
26+ default: /var/lib/buildbot/slaves/slave
27
28=== modified file 'hooks/install'
29--- hooks/install 2012-02-09 10:44:48 +0000
30+++ hooks/install 2012-02-10 01:16:25 +0000
31@@ -7,11 +7,16 @@
32 apt_get_install,
33 command,
34 get_config,
35+ install_extra_repository,
36 log,
37 log_entry,
38 log_exit,
39 run,
40 )
41+from local import (
42+ config_json,
43+ create_slave,
44+ )
45 import os
46 import shlex
47 import subprocess
48@@ -40,21 +45,21 @@
49
50 def wget(source, path):
51 target = os.path.join('/tmp', path)
52- command('wget', '-O', target, source)
53+ run('wget', '-O', target, source)
54 return target
55
56
57 def hg_fetch(source, path):
58 apt_get_install('mercurial')
59 target = tempfile.mktemp()
60- command('hg', 'clone', source, target)
61+ run('hg', 'clone', source, target)
62 return os.path.join(target, path)
63
64
65 def git_fetch(source, path):
66 apt_get_install('git')
67 target = tempfile.mktemp()
68- command('git', 'clone', source, target)
69+ run('git', 'clone', source, target)
70 return os.path.join(target, path)
71
72
73@@ -82,9 +87,33 @@
74 url = config.get('script-url')
75 path = config.get('script-path')
76 args = config.get('script-args')
77+ buildbot_pkg = config.get('buildbot-pkg')
78+ extra_repo = config.get('extra-repository')
79+ buildbot_dir = config.get('installdir')
80+
81+ if extra_repo:
82+ install_extra_repository(extra_repo)
83+
84+ if buildbot_pkg:
85+ log('Installing ' + buildbot_pkg)
86+ apt_get_install(buildbot_pkg)
87+ log('Creating initial buildbot slave in ' + buildbot_dir)
88+ create_slave('temporary', 'temporary', buildbot_dir=buildbot_dir)
89+
90+ config_json.set(config)
91+
92 retrieve = METHODS.get(method)
93 if retrieve and url and path:
94- sys.exit(handle_script(retrieve, url, path, args))
95+ # Make buildbot user have a shell by editing /etc/passwd.
96+ # Otherwise you cannot ssh as this user, which some scripts
97+ # need (e.g. those that create lxc containers). We choose sh as
98+ # a standard and basic "system" shell.
99+ run('usermod', '-s', '/bin/sh', 'buildbot')
100+ # This is naive; we can make it more sophisticated (e.g., allowing
101+ # escaping dollar signs) if we discover we need it. For now,
102+ # simplicity wins.
103+ replaced_args = args.replace('$INSTALLDIR', buildbot_dir)
104+ sys.exit(handle_script(retrieve, url, path, replaced_args))
105
106
107 if __name__ == '__main__':

Subscribers

People subscribed via source and target branches

to all changes: