Merge ~cjwatson/launchpad:rename-builder-interactor-slave into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 49163ad5cdf93c027e62fd51dea09bdf52ef6d12
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:rename-builder-interactor-slave
Merge into: launchpad:master
Prerequisite: ~cjwatson/launchpad:rename-bfj-behaviour-slave
Diff against target: 392 lines (+65/-65)
4 files modified
lib/lp/buildmaster/interactor.py (+32/-32)
lib/lp/buildmaster/manager.py (+3/-3)
lib/lp/buildmaster/tests/test_interactor.py (+29/-29)
lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py (+1/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc Approve
Review via email: mp+414045@code.launchpad.net

Commit message

Rename "slave" in BuilderInteractor to "worker"

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py
2index 3aaae63..e8a1d7f 100644
3--- a/lib/lp/buildmaster/interactor.py
4+++ b/lib/lp/buildmaster/interactor.py
5@@ -345,7 +345,7 @@ def extract_vitals_from_db(builder, build_queue=_BQ_UNSPECIFIED):
6 class BuilderInteractor:
7
8 @staticmethod
9- def makeSlaveFromVitals(vitals):
10+ def makeWorkerFromVitals(vitals):
11 if vitals.virtualized:
12 timeout = config.builddmaster.virtualized_socket_timeout
13 else:
14@@ -354,19 +354,19 @@ class BuilderInteractor:
15 vitals.url, vitals.vm_host, timeout)
16
17 @staticmethod
18- def getBuildBehaviour(queue_item, builder, slave):
19+ def getBuildBehaviour(queue_item, builder, worker):
20 if queue_item is None:
21 return None
22 behaviour = IBuildFarmJobBehaviour(queue_item.specific_build)
23- behaviour.setBuilder(builder, slave)
24+ behaviour.setBuilder(builder, worker)
25 return behaviour
26
27 @classmethod
28- def resumeSlaveHost(cls, vitals, slave):
29- """Resume the slave host to a known good condition.
30+ def resumeWorkerHost(cls, vitals, worker):
31+ """Resume the worker host to a known good condition.
32
33 Issues 'builddmaster.vm_resume_command' specified in the configuration
34- to resume the slave.
35+ to resume the worker.
36
37 :raises: CannotResumeHost: if builder is not virtual or if the
38 configuration command has failed.
39@@ -384,7 +384,7 @@ class BuilderInteractor:
40 logger = cls._getWorkerScannerLogger()
41 logger.info("Resuming %s (%s)" % (vitals.name, vitals.url))
42
43- d = slave.resume()
44+ d = worker.resume()
45
46 def got_resume_ok(args):
47 stdout, stderr, returncode = args
48@@ -400,38 +400,38 @@ class BuilderInteractor:
49
50 @classmethod
51 @defer.inlineCallbacks
52- def cleanSlave(cls, vitals, slave, builder_factory):
53- """Prepare a slave for a new build.
54+ def cleanWorker(cls, vitals, worker, builder_factory):
55+ """Prepare a worker for a new build.
56
57 :return: A Deferred that fires when this stage of the resume
58- operations finishes. If the value is True, the slave is now clean.
59+ operations finishes. If the value is True, the worker is now clean.
60 If it's False, the clean is still in progress and this must be
61 called again later.
62 """
63 if vitals.virtualized:
64 if vitals.vm_reset_protocol == BuilderResetProtocol.PROTO_1_1:
65 # In protocol 1.1 the reset trigger is synchronous, so
66- # once resumeSlaveHost returns the slave should be
67+ # once resumeWorkerHost returns the worker should be
68 # running.
69 builder_factory[vitals.name].setCleanStatus(
70 BuilderCleanStatus.CLEANING)
71 transaction.commit()
72- yield cls.resumeSlaveHost(vitals, slave)
73- # We ping the resumed slave before we try to do anything
74+ yield cls.resumeWorkerHost(vitals, worker)
75+ # We ping the resumed worker before we try to do anything
76 # useful with it. This is to ensure it's accepting
77 # packets from the outside world, because testing has
78 # shown that the first packet will randomly fail for no
79 # apparent reason. This could be a quirk of the Xen
80 # guest, we're not sure. See bug 586359.
81- yield slave.echo("ping")
82+ yield worker.echo("ping")
83 return True
84 elif vitals.vm_reset_protocol == BuilderResetProtocol.PROTO_2_0:
85 # In protocol 2.0 the reset trigger is asynchronous.
86- # If the trigger succeeds we'll leave the slave in
87- # CLEANING, and the non-LP slave management code will
88+ # If the trigger succeeds we'll leave the worker in
89+ # CLEANING, and the non-LP worker management code will
90 # set it back to CLEAN later using the webservice.
91 if vitals.clean_status == BuilderCleanStatus.DIRTY:
92- yield cls.resumeSlaveHost(vitals, slave)
93+ yield cls.resumeWorkerHost(vitals, worker)
94 builder_factory[vitals.name].setCleanStatus(
95 BuilderCleanStatus.CLEANING)
96 transaction.commit()
97@@ -441,28 +441,28 @@ class BuilderInteractor:
98 raise CannotResumeHost(
99 "Invalid vm_reset_protocol: %r" % vitals.vm_reset_protocol)
100 else:
101- worker_status = yield slave.status()
102+ worker_status = yield worker.status()
103 status = worker_status.get('builder_status', None)
104 if status == 'BuilderStatus.IDLE':
105 # This is as clean as we can get it.
106 return True
107 elif status == 'BuilderStatus.BUILDING':
108- # Asynchronously abort() the slave and wait until WAITING.
109- yield slave.abort()
110+ # Asynchronously abort() the worker and wait until WAITING.
111+ yield worker.abort()
112 return False
113 elif status == 'BuilderStatus.ABORTING':
114 # Wait it out until WAITING.
115 return False
116 elif status == 'BuilderStatus.WAITING':
117 # Just a synchronous clean() call and we'll be idle.
118- yield slave.clean()
119+ yield worker.clean()
120 return True
121 raise BuildDaemonError(
122 "Invalid status during clean: %r" % status)
123
124 @classmethod
125 @defer.inlineCallbacks
126- def _startBuild(cls, build_queue_item, vitals, builder, slave, behaviour,
127+ def _startBuild(cls, build_queue_item, vitals, builder, worker, behaviour,
128 logger):
129 """Start a build on this builder.
130
131@@ -482,7 +482,7 @@ class BuilderInteractor:
132
133 if builder.clean_status != BuilderCleanStatus.CLEAN:
134 raise BuildDaemonIsolationError(
135- "Attempted to start build on a dirty slave.")
136+ "Attempted to start build on a dirty worker.")
137
138 builder.setCleanStatus(BuilderCleanStatus.DIRTY)
139 transaction.commit()
140@@ -491,8 +491,8 @@ class BuilderInteractor:
141
142 @classmethod
143 @defer.inlineCallbacks
144- def findAndStartJob(cls, vitals, builder, slave, builder_factory):
145- """Find a job to run and send it to the buildd slave.
146+ def findAndStartJob(cls, vitals, builder, worker, builder_factory):
147+ """Find a job to run and send it to the buildd worker.
148
149 :return: A Deferred whose value is the `IBuildQueue` instance
150 found or None if no job was found.
151@@ -514,7 +514,7 @@ class BuilderInteractor:
152 logger.debug("No build candidates available for builder.")
153 return None
154
155- new_behaviour = cls.getBuildBehaviour(candidate, builder, slave)
156+ new_behaviour = cls.getBuildBehaviour(candidate, builder, worker)
157 needed_bfjb = type(removeSecurityProxy(
158 IBuildFarmJobBehaviour(candidate.specific_build)))
159 if not zope_isinstance(new_behaviour, needed_bfjb):
160@@ -522,7 +522,7 @@ class BuilderInteractor:
161 "Inappropriate IBuildFarmJobBehaviour: %r is not a %r" %
162 (new_behaviour, needed_bfjb))
163 yield cls._startBuild(
164- candidate, vitals, builder, slave, new_behaviour, logger)
165+ candidate, vitals, builder, worker, new_behaviour, logger)
166 return candidate
167
168 @staticmethod
169@@ -549,7 +549,7 @@ class BuilderInteractor:
170 """
171 builder_status = worker_status["builder_status"]
172 if builder_status == "BuilderStatus.ABORTING":
173- logtail = "Waiting for slave process to be terminated"
174+ logtail = "Waiting for worker process to be terminated"
175 elif worker_status.get("logtail") is not None:
176 # worker_status["logtail"] is an xmlrpc.client.Binary instance,
177 # and the contents might include invalid UTF-8 due to being a
178@@ -567,16 +567,16 @@ class BuilderInteractor:
179
180 @classmethod
181 @defer.inlineCallbacks
182- def updateBuild(cls, vitals, slave, worker_status, builder_factory,
183+ def updateBuild(cls, vitals, worker, worker_status, builder_factory,
184 behaviour_factory, manager):
185 """Verify the current build job status.
186
187 Perform the required actions for each state.
188
189- :return: A Deferred that fires when the slave dialog is finished.
190+ :return: A Deferred that fires when the worker dialog is finished.
191 """
192 # IDLE is deliberately not handled here, because it should be
193- # impossible to get past the cookie check unless the slave
194+ # impossible to get past the cookie check unless the worker
195 # matches the DB, and this method isn't called unless the DB
196 # says there's a job.
197 builder_status = worker_status['builder_status']
198@@ -592,7 +592,7 @@ class BuilderInteractor:
199 elif builder_status == 'BuilderStatus.WAITING':
200 # Build has finished. Delegate handling to the build itself.
201 builder = builder_factory[vitals.name]
202- behaviour = behaviour_factory(vitals.build_queue, builder, slave)
203+ behaviour = behaviour_factory(vitals.build_queue, builder, worker)
204 yield behaviour.handleStatus(
205 vitals.build_queue, cls.extractBuildStatus(worker_status),
206 worker_status)
207diff --git a/lib/lp/buildmaster/manager.py b/lib/lp/buildmaster/manager.py
208index ba9c3f1..850b83b 100644
209--- a/lib/lp/buildmaster/manager.py
210+++ b/lib/lp/buildmaster/manager.py
211@@ -431,7 +431,7 @@ class WorkerScanner:
212
213 def __init__(self, builder_name, builder_factory, manager, logger,
214 clock=None, interactor_factory=BuilderInteractor,
215- worker_factory=BuilderInteractor.makeSlaveFromVitals,
216+ worker_factory=BuilderInteractor.makeWorkerFromVitals,
217 behaviour_factory=BuilderInteractor.getBuildBehaviour):
218 self.builder_name = builder_name
219 self.builder_factory = builder_factory
220@@ -681,11 +681,11 @@ class WorkerScanner:
221 builder.resetFailureCount()
222 transaction.commit()
223 else:
224- # Ask the BuilderInteractor to clean the slave. It might
225+ # Ask the BuilderInteractor to clean the worker. It might
226 # be immediately cleaned on return, in which case we go
227 # straight back to CLEAN, or we might have to spin
228 # through another few cycles.
229- done = yield interactor.cleanSlave(
230+ done = yield interactor.cleanWorker(
231 vitals, slave, self.builder_factory)
232 if done:
233 builder = self.builder_factory[self.builder_name]
234diff --git a/lib/lp/buildmaster/tests/test_interactor.py b/lib/lp/buildmaster/tests/test_interactor.py
235index fc102be..6e4a790 100644
236--- a/lib/lp/buildmaster/tests/test_interactor.py
237+++ b/lib/lp/buildmaster/tests/test_interactor.py
238@@ -123,7 +123,7 @@ class TestBuilderInteractor(TestCase):
239
240 def test_extractBuildStatus_baseline(self):
241 # extractBuildStatus picks the name of the build status out of a
242- # dict describing the slave's status.
243+ # dict describing the worker's status.
244 worker_status = {'build_status': 'BuildStatus.BUILDING'}
245 self.assertEqual(
246 'BUILDING', BuilderInteractor.extractBuildStatus(worker_status))
247@@ -136,20 +136,20 @@ class TestBuilderInteractor(TestCase):
248 AssertionError, BuilderInteractor.extractBuildStatus,
249 worker_status)
250
251- def resumeSlaveHost(self, builder):
252+ def resumeWorkerHost(self, builder):
253 vitals = extract_vitals_from_db(builder)
254- return BuilderInteractor.resumeSlaveHost(
255- vitals, BuilderInteractor.makeSlaveFromVitals(vitals))
256+ return BuilderInteractor.resumeWorkerHost(
257+ vitals, BuilderInteractor.makeWorkerFromVitals(vitals))
258
259- def test_resumeSlaveHost_nonvirtual(self):
260- d = self.resumeSlaveHost(MockBuilder(virtualized=False))
261+ def test_resumeWorkerHost_nonvirtual(self):
262+ d = self.resumeWorkerHost(MockBuilder(virtualized=False))
263 return assert_fails_with(d, CannotResumeHost)
264
265- def test_resumeSlaveHost_no_vmhost(self):
266- d = self.resumeSlaveHost(MockBuilder(virtualized=False, vm_host=None))
267+ def test_resumeWorkerHost_no_vmhost(self):
268+ d = self.resumeWorkerHost(MockBuilder(virtualized=False, vm_host=None))
269 return assert_fails_with(d, CannotResumeHost)
270
271- def test_resumeSlaveHost_success(self):
272+ def test_resumeWorkerHost_success(self):
273 reset_config = """
274 [builddmaster]
275 vm_resume_command: /bin/echo -n snap %(buildd_name)s %(vm_host)s
276@@ -157,45 +157,45 @@ class TestBuilderInteractor(TestCase):
277 config.push('reset', reset_config)
278 self.addCleanup(config.pop, 'reset')
279
280- d = self.resumeSlaveHost(MockBuilder(
281+ d = self.resumeWorkerHost(MockBuilder(
282 url="http://crackle.ppa/", virtualized=True, vm_host="pop"))
283
284 def got_resume(output):
285 self.assertEqual((b'snap crackle pop', b''), output)
286 return d.addCallback(got_resume)
287
288- def test_resumeSlaveHost_command_failed(self):
289+ def test_resumeWorkerHost_command_failed(self):
290 reset_fail_config = """
291 [builddmaster]
292 vm_resume_command: /bin/false"""
293 config.push('reset fail', reset_fail_config)
294 self.addCleanup(config.pop, 'reset fail')
295- d = self.resumeSlaveHost(MockBuilder(virtualized=True, vm_host="pop"))
296+ d = self.resumeWorkerHost(MockBuilder(virtualized=True, vm_host="pop"))
297 return assert_fails_with(d, CannotResumeHost)
298
299- def test_makeSlaveFromVitals(self):
300- # Builder.slave is a BuilderWorker that points at the actual Builder.
301- # The Builder is only ever used in scripts that run outside of the
302- # security context.
303+ def test_makeWorkerFromVitals(self):
304+ # BuilderInteractor.makeWorkerFromVitals returns a BuilderWorker
305+ # that points at the actual Builder. The Builder is only ever used
306+ # in scripts that run outside of the security context.
307 builder = MockBuilder(virtualized=False)
308 vitals = extract_vitals_from_db(builder)
309- slave = BuilderInteractor.makeSlaveFromVitals(vitals)
310- self.assertEqual(builder.url, slave.url)
311- self.assertEqual(10, slave.timeout)
312+ worker = BuilderInteractor.makeWorkerFromVitals(vitals)
313+ self.assertEqual(builder.url, worker.url)
314+ self.assertEqual(10, worker.timeout)
315
316 builder = MockBuilder(virtualized=True)
317 vitals = extract_vitals_from_db(builder)
318- slave = BuilderInteractor.makeSlaveFromVitals(vitals)
319- self.assertEqual(5, slave.timeout)
320+ worker = BuilderInteractor.makeWorkerFromVitals(vitals)
321+ self.assertEqual(5, worker.timeout)
322
323
324-class TestBuilderInteractorCleanSlave(TestCase):
325+class TestBuilderInteractorCleanWorker(TestCase):
326
327 run_tests_with = AsynchronousDeferredRunTest
328
329 @defer.inlineCallbacks
330 def assertCleanCalls(self, builder, worker, calls, done):
331- actually_done = yield BuilderInteractor.cleanSlave(
332+ actually_done = yield BuilderInteractor.cleanWorker(
333 extract_vitals_from_db(builder), worker,
334 MockBuilderFactory(builder, None))
335 self.assertEqual(done, actually_done)
336@@ -243,7 +243,7 @@ class TestBuilderInteractorCleanSlave(TestCase):
337 builder.vm_reset_protocol = None
338 with ExpectedException(
339 CannotResumeHost, "Invalid vm_reset_protocol: None"):
340- yield BuilderInteractor.cleanSlave(
341+ yield BuilderInteractor.cleanWorker(
342 extract_vitals_from_db(builder), OkWorker(),
343 MockBuilderFactory(builder, None))
344
345@@ -290,7 +290,7 @@ class TestBuilderInteractorCleanSlave(TestCase):
346 vitals = extract_vitals_from_db(builder)
347 worker = LostBuildingBrokenWorker()
348 try:
349- yield BuilderInteractor.cleanSlave(
350+ yield BuilderInteractor.cleanWorker(
351 vitals, worker, MockBuilderFactory(builder, None))
352 except xmlrpc.client.Fault:
353 self.assertEqual(['status', 'abort'], worker.call_log)
354@@ -470,8 +470,8 @@ class TestBuilderInteractorDB(TestCaseWithFactory):
355 return d.addCallback(check_build_started)
356
357 @defer.inlineCallbacks
358- def test_findAndStartJob_requires_clean_slave(self):
359- # findAndStartJob ensures that its slave starts CLEAN.
360+ def test_findAndStartJob_requires_clean_worker(self):
361+ # findAndStartJob ensures that its worker starts CLEAN.
362 builder, build = self._setupBinaryBuildAndBuilder()
363 builder.setCleanStatus(BuilderCleanStatus.DIRTY)
364 candidate = build.queueBuild()
365@@ -480,12 +480,12 @@ class TestBuilderInteractorDB(TestCaseWithFactory):
366 vitals = extract_vitals_from_db(builder)
367 with ExpectedException(
368 BuildDaemonIsolationError,
369- "Attempted to start build on a dirty slave."):
370+ "Attempted to start build on a dirty worker."):
371 yield BuilderInteractor.findAndStartJob(
372 vitals, builder, OkWorker(), builder_factory)
373
374 @defer.inlineCallbacks
375- def test_findAndStartJob_dirties_slave(self):
376+ def test_findAndStartJob_dirties_worker(self):
377 # findAndStartJob marks its builder DIRTY before dispatching.
378 builder, build = self._setupBinaryBuildAndBuilder()
379 candidate = build.queueBuild()
380diff --git a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
381index 89f8474..73bff8d 100644
382--- a/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
383+++ b/lib/lp/soyuz/tests/test_binarypackagebuildbehaviour.py
384@@ -615,7 +615,7 @@ class TestBinaryBuildPackageBehaviourBuildCollection(TestCaseWithFactory):
385 # The builder is in the process of aborting.
386 def got_update(ignored):
387 self.assertEqual(
388- "Waiting for slave process to be terminated",
389+ "Waiting for worker process to be terminated",
390 self.candidate.logtail)
391
392 d = self.updateBuild(self.candidate, AbortingWorker())

Subscribers

People subscribed via source and target branches

to status/vote changes: