Merge lp:~mbp/launchpad/800295-buildd-split into lp:launchpad

Proposed by Martin Pool
Status: Merged
Approved by: Martin Pool
Approved revision: no longer in the source branch.
Merged at revision: 14248
Proposed branch: lp:~mbp/launchpad/800295-buildd-split
Merge into: lp:launchpad
Diff against target: 172 lines (+45/-19)
5 files modified
lib/canonical/buildd/buildd-slave.tac (+3/-10)
lib/canonical/buildd/debian/changelog (+8/-0)
lib/canonical/buildd/debian/rules (+1/-5)
lib/canonical/buildd/tests/harness.py (+12/-4)
lib/canonical/launchpad/daemons/tachandler.py (+21/-0)
To merge this branch: bzr merge lp:~mbp/launchpad/800295-buildd-split
Reviewer Review Type Date Requested Status
Julian Edwards (community) Needs Information
Review via email: mp+81111@code.launchpad.net

Commit message

[r=mbp][bug=800295] [no-qa] prune dependencies between buildd and the rest of Launchpad

Description of the change

This is a partial fix for bug 800295, splitting all the files shared between buildd and lp proper into one or the other.

Beyond this we might like to split them in to separate trees, but I thought this would be easier to review and test by itself.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

This will fail tests. the daemon is used and tested from the lp tree,
which is what readyservice is for.

Revision history for this message
Martin Pool (mbp) wrote :

I should probably move 'wait for the port' up to the base class.

Revision history for this message
Julian Edwards (julian-edwards) wrote :

I can't see where _hasDaemonStarted() is getting called from here. It's called in the whole tree from only one place in lib/canonical/launchpad/daemons/tachandler.py but I can't see how it's replacing the readyService in the buildd code.

Am I missing something or are you? :)

review: Needs Information
Revision history for this message
Martin Pool (mbp) wrote :

_hasDaemonStarted is called from the TestTacServer base class; I'm overriding it here so that the fixture decides the server is ready not when it writes to the log, but rather when the daemon starts listening on its port. That general concept could usefully go into the base class, with the subclass just defining the port.

This patch as it is passes all tests, and it removes the need to actually copy files from the lp tree into the buildd directory. It doesn't make it possible to run the buildd tests without the Launchpad tree, which would be useful to do to make it totally split out.

Revision history for this message
Martin Pool (mbp) wrote :

The current version of this does everything short of cutting things in to separate packages. The buildd code no longer (I think) depends on anything from the rest of lp except TacTestSetup.

The next steps are to split out TacTestSetup into one package, and then to split the buildd itself.

Revision history for this message
Martin Pool (mbp) wrote :

... I'd like to do those splits as separate mps because they'll be harder to reviews (since they will mostly just look like deletions.)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== renamed file 'daemons/buildd-slave.tac' => 'lib/canonical/buildd/buildd-slave.tac'
2--- daemons/buildd-slave.tac 2011-06-21 17:07:05 +0000
3+++ lib/canonical/buildd/buildd-slave.tac 2011-11-04 01:08:26 +0000
4@@ -1,12 +1,9 @@
5 # Copyright 2009-2011 Canonical Ltd. This software is licensed under the
6 # GNU Affero General Public License version 3 (see the file LICENSE).
7
8-# XXX: JonathanLange 2011-06-21 bug=800295: The only modules in the Launchpad
9-# tree that this is permitted to depend on are canonical.buildd and
10-# canonical.launchpad.daemons.readyservice, since canonical.buildd is deployed
11-# by copying lib/canonical/buildd,
12-# lib/canonical/launchpad/daemons/readyservice.py and daemons/buildd-slave.tac
13-# only.
14+# CAUTION: The only modules in the Launchpad tree that this is permitted to
15+# depend on are canonical.buildd, since buildds are deployed by copying that
16+# directory only. (See also bug=800295.)
17
18 # Buildd Slave implementation
19 # XXX: dsilvers: 2005/01/21: Currently everything logged in the slave gets
20@@ -19,7 +16,6 @@
21 SourcePackageRecipeBuildManager)
22 from canonical.buildd.translationtemplates import (
23 TranslationTemplatesBuildManager)
24-from canonical.launchpad.daemons import readyservice
25
26 from twisted.web import server, resource, static
27 from ConfigParser import SafeConfigParser
28@@ -42,9 +38,6 @@
29 application = service.Application('BuildDSlave')
30 builddslaveService = service.IServiceCollection(application)
31
32-# Service that announces when the daemon is ready
33-readyservice.ReadyService().setServiceParent(builddslaveService)
34-
35 root = resource.Resource()
36 root.putChild('rpc', slave)
37 root.putChild('filecache', static.File(conf.get('slave', 'filecache')))
38
39=== modified file 'lib/canonical/buildd/debian/changelog'
40--- lib/canonical/buildd/debian/changelog 2011-10-17 13:12:47 +0000
41+++ lib/canonical/buildd/debian/changelog 2011-11-04 01:08:26 +0000
42@@ -1,3 +1,11 @@
43+launchpad-buildd (82) hardy-cat; urgency=low
44+
45+ * Cut out readyservice from the buildds. LP: #800295
46+ * buildrecipe shows the bzr and bzr-builder versions. LP: #884092
47+ * buildrecipe shows bzr rusage. LP: 884997
48+
49+ -- Martin Pool <mbp@canonical.com> Thu, 03 Nov 2011 17:11:25 +1100
50+
51 launchpad-buildd (81) hardy-cat; urgency=low
52
53 * generate-translation-templates: switch to Python 2.7.
54
55=== modified file 'lib/canonical/buildd/debian/rules'
56--- lib/canonical/buildd/debian/rules 2010-10-20 18:43:29 +0000
57+++ lib/canonical/buildd/debian/rules 2011-11-04 01:08:26 +0000
58@@ -14,7 +14,6 @@
59 target = debian/launchpad-buildd
60 topdir = ../../..
61
62-daemons = $(topdir)/daemons
63 buildd = $(topdir)/lib/canonical/buildd
64
65 targetshare = $(target)/usr/share/launchpad-buildd
66@@ -45,8 +44,7 @@
67 # Do installs here
68 touch $(pytarget)/../launchpad/__init__.py
69 touch $(pytarget)/../launchpad/daemons/__init__.py
70- cp launchpad-files/readyservice.py $(pytarget)/../launchpad/daemons/
71- install -m644 launchpad-files/buildd-slave.tac $(targetshare)/buildd-slave.tac
72+ install -m644 buildd-slave.tac $(targetshare)/buildd-slave.tac
73 cp -r pottery $(pytarget)
74 for pyfile in $(pyfiles); do \
75 install -m644 ./$$pyfile $(pytarget)/$$pyfile; \
76@@ -90,8 +88,6 @@
77 dh_clean
78
79 prepare:
80- install -m644 $(daemons)/buildd-slave.tac launchpad-files/buildd-slave.tac
81- cp ../launchpad/daemons/readyservice.py launchpad-files/readyservice.py
82
83 package: prepare
84 debuild -uc -us -S
85
86=== modified file 'lib/canonical/buildd/tests/harness.py'
87--- lib/canonical/buildd/tests/harness.py 2010-09-28 11:05:14 +0000
88+++ lib/canonical/buildd/tests/harness.py 2011-11-04 01:08:26 +0000
89@@ -1,9 +1,8 @@
90-# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
91+# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
92 # GNU Affero General Public License version 3 (see the file LICENSE).
93
94 __metaclass__ = type
95 __all__ = [
96- 'BuildlogSecurityTests',
97 'BuilddTestCase',
98 ]
99
100@@ -13,6 +12,7 @@
101 from ConfigParser import SafeConfigParser
102
103 import canonical
104+import canonical.buildd
105
106 from canonical.buildd.slave import BuildDSlave
107 from canonical.launchpad.daemons.tachandler import TacTestSetup
108@@ -119,8 +119,8 @@
109 @property
110 def tacfile(self):
111 return os.path.abspath(os.path.join(
112- os.path.dirname(canonical.__file__), os.pardir, os.pardir,
113- 'daemons/buildd-slave.tac'
114+ os.path.dirname(canonical.buildd.__file__),
115+ 'buildd-slave.tac'
116 ))
117
118 @property
119@@ -130,3 +130,11 @@
120 @property
121 def logfile(self):
122 return '/var/tmp/build-slave.log'
123+
124+ def _hasDaemonStarted(self):
125+ """Called by the superclass to check if the daemon is listening.
126+
127+ The slave is ready when it's accepting connections.
128+ """
129+ # This must match buildd-slave-test.conf.
130+ return self._isPortListening('localhost', 8221)
131
132=== modified file 'lib/canonical/launchpad/daemons/tachandler.py'
133--- lib/canonical/launchpad/daemons/tachandler.py 2011-08-19 15:36:31 +0000
134+++ lib/canonical/launchpad/daemons/tachandler.py 2011-11-04 01:08:26 +0000
135@@ -11,7 +11,9 @@
136 ]
137
138
139+import errno
140 import os
141+import socket
142 import subprocess
143 import sys
144 import time
145@@ -115,6 +117,25 @@
146 else:
147 return False
148
149+ def _isPortListening(self, host, port):
150+ """True if a tcp port is accepting connections.
151+
152+ This can be used by subclasses overriding _hasDaemonStarted, if they
153+ want to check the port is up rather than for the contents of the log
154+ file.
155+ """
156+ try:
157+ s = socket.socket()
158+ s.settimeout(2.0)
159+ s.connect((host, port))
160+ s.close()
161+ return True
162+ except socket.error, e:
163+ if e.errno == errno.ECONNREFUSED:
164+ return False
165+ else:
166+ raise
167+
168 def _waitForDaemonStartup(self):
169 """ Wait for the daemon to fully start.
170
171
172=== renamed file 'lib/canonical/buildd/tests/test_generate_translation_templates.py' => 'lib/lp/translations/tests/test_generate_translation_templates.py'