← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:rename-slave-scanner into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:rename-slave-scanner into launchpad:master with ~cjwatson/launchpad:rename-mock-builder-slaves as a prerequisite.

Commit message:
Rename SlaveScanner to WorkerScanner

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/413975
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:rename-slave-scanner into launchpad:master.
diff --git a/lib/lp/buildmaster/interactor.py b/lib/lp/buildmaster/interactor.py
index ea8c962..6b51df7 100644
--- a/lib/lp/buildmaster/interactor.py
+++ b/lib/lp/buildmaster/interactor.py
@@ -381,7 +381,7 @@ class BuilderInteractor:
         if not vitals.vm_host:
             return defer.fail(CannotResumeHost('Undefined vm_host.'))
 
-        logger = cls._getSlaveScannerLogger()
+        logger = cls._getWorkerScannerLogger()
         logger.info("Resuming %s (%s)" % (vitals.name, vitals.url))
 
         d = slave.resume()
@@ -435,7 +435,7 @@ class BuilderInteractor:
                     builder_factory[vitals.name].setCleanStatus(
                         BuilderCleanStatus.CLEANING)
                     transaction.commit()
-                    logger = cls._getSlaveScannerLogger()
+                    logger = cls._getWorkerScannerLogger()
                     logger.info("%s is being cleaned.", vitals.name)
                 return False
             raise CannotResumeHost(
@@ -497,7 +497,7 @@ class BuilderInteractor:
         :return: A Deferred whose value is the `IBuildQueue` instance
             found or None if no job was found.
         """
-        logger = cls._getSlaveScannerLogger()
+        logger = cls._getWorkerScannerLogger()
         # Try a few candidates so that we make reasonable progress if we
         # have only a few idle builders but lots of candidates that fail
         # postprocessing due to old source publications or similar.  The
@@ -600,11 +600,11 @@ class BuilderInteractor:
             raise AssertionError("Unknown status %s" % builder_status)
 
     @staticmethod
-    def _getSlaveScannerLogger():
-        """Return the logger instance from buildd-slave-scanner.py."""
+    def _getWorkerScannerLogger():
+        """Return the logger instance from lp.buildmaster.manager."""
         # XXX cprov 20071120: Ideally the Launchpad logging system
         # should be able to configure the root-logger instead of creating
         # a new object, then the logger lookups won't require the specific
         # name argument anymore. See bug 164203.
-        logger = logging.getLogger('slave-scanner')
+        logger = logging.getLogger('worker-scanner')
         return logger
diff --git a/lib/lp/buildmaster/manager.py b/lib/lp/buildmaster/manager.py
index b78c912..1ad0c9d 100644
--- a/lib/lp/buildmaster/manager.py
+++ b/lib/lp/buildmaster/manager.py
@@ -1,13 +1,13 @@
 # Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-"""Soyuz buildd slave manager logic."""
+"""Soyuz buildd worker manager logic."""
 
 __all__ = [
     'BuilddManager',
     'BUILDD_MANAGER_LOG_NAME',
     'PrefetchedBuilderFactory',
-    'SlaveScanner',
+    'WorkerScanner',
     ]
 
 from collections import defaultdict
@@ -63,7 +63,7 @@ from lp.services.propertycache import get_property_cache
 from lp.services.statsd.interfaces.statsd_client import IStatsdClient
 
 
-BUILDD_MANAGER_LOG_NAME = "slave-scanner"
+BUILDD_MANAGER_LOG_NAME = "worker-scanner"
 
 
 # The number of times a builder can consecutively fail before we
@@ -410,7 +410,7 @@ def recover_failure(logger, vitals, builder, retry, exception):
         builder.setCleanStatus(BuilderCleanStatus.DIRTY)
 
 
-class SlaveScanner:
+class WorkerScanner:
     """A manager for a single builder."""
 
     # The interval between each poll cycle, in seconds.  We'd ideally
@@ -431,14 +431,14 @@ class SlaveScanner:
 
     def __init__(self, builder_name, builder_factory, manager, logger,
                  clock=None, interactor_factory=BuilderInteractor,
-                 slave_factory=BuilderInteractor.makeSlaveFromVitals,
+                 worker_factory=BuilderInteractor.makeSlaveFromVitals,
                  behaviour_factory=BuilderInteractor.getBuildBehaviour):
         self.builder_name = builder_name
         self.builder_factory = builder_factory
         self.manager = manager
         self.logger = logger
         self.interactor_factory = interactor_factory
-        self.slave_factory = slave_factory
+        self.worker_factory = worker_factory
         self.behaviour_factory = behaviour_factory
         # Use the clock if provided, so that tests can advance it.  Use the
         # reactor by default.
@@ -606,7 +606,7 @@ class SlaveScanner:
         self.builder_factory.prescanUpdate()
         vitals = self.builder_factory.getVitals(self.builder_name)
         interactor = self.interactor_factory()
-        slave = self.slave_factory(vitals)
+        slave = self.worker_factory(vitals)
 
         if vitals.build_queue is not None:
             if vitals.clean_status != BuilderCleanStatus.DIRTY:
@@ -709,7 +709,7 @@ class BuilddManager(service.Service):
         if clock is None:
             clock = reactor
         self._clock = clock
-        self.builder_slaves = []
+        self.workers = []
         self.builder_factory = builder_factory or PrefetchedBuilderFactory()
         self.logger = self._setupLogger()
         self.current_builders = []
@@ -717,7 +717,7 @@ class BuilddManager(service.Service):
         self.statsd_client = getUtility(IStatsdClient)
 
     def _setupLogger(self):
-        """Set up a 'slave-scanner' logger that redirects to twisted.
+        """Set up a 'worker-scanner' logger that redirects to twisted.
 
         Make it less verbose to avoid messing too much with the old code.
         """
@@ -796,7 +796,7 @@ class BuilddManager(service.Service):
 
     def startService(self):
         """Service entry point, called when the application starts."""
-        # Add and start SlaveScanners for each current builder, and any
+        # Add and start WorkerScanners for each current builder, and any
         # added in the future.
         self.scan_builders_loop, self.scan_builders_deferred = (
             self._startLoop(self.SCAN_BUILDERS_INTERVAL, self.scanBuilders))
@@ -807,15 +807,15 @@ class BuilddManager(service.Service):
     def stopService(self):
         """Callback for when we need to shut down."""
         # XXX: lacks unit tests
-        # All the SlaveScanner objects need to be halted gracefully.
-        deferreds = [slave.stopping_deferred for slave in self.builder_slaves]
+        # All the WorkerScanner objects need to be halted gracefully.
+        deferreds = [worker.stopping_deferred for worker in self.workers]
         deferreds.append(self.scan_builders_deferred)
         deferreds.append(self.flush_logtails_deferred)
 
         self.flush_logtails_loop.stop()
         self.scan_builders_loop.stop()
-        for slave in self.builder_slaves:
-            slave.stopCycle()
+        for worker in self.workers:
+            worker.stopCycle()
 
         # The 'stopping_deferred's are called back when the loops are
         # stopped, so we can wait on them all at once here before
@@ -826,10 +826,10 @@ class BuilddManager(service.Service):
     def addScanForBuilders(self, builders):
         """Set up scanner objects for the builders specified."""
         for builder in builders:
-            slave_scanner = SlaveScanner(
+            worker_scanner = WorkerScanner(
                 builder, self.builder_factory, self, self.logger)
-            self.builder_slaves.append(slave_scanner)
-            slave_scanner.startCycle()
+            self.workers.append(worker_scanner)
+            worker_scanner.startCycle()
 
-        # Return the slave list for the benefit of tests.
-        return self.builder_slaves
+        # Return the worker list for the benefit of tests.
+        return self.workers
diff --git a/lib/lp/buildmaster/model/buildqueue.py b/lib/lp/buildmaster/model/buildqueue.py
index f82102d..1bc3b0d 100644
--- a/lib/lp/buildmaster/model/buildqueue.py
+++ b/lib/lp/buildmaster/model/buildqueue.py
@@ -290,13 +290,13 @@ class BuildQueueSet:
             get_property_cache(build).buildqueue_record = bq
         return bqs
 
-    def _getSlaveScannerLogger(self):
-        """Return the logger instance from buildd-slave-scanner.py."""
+    def _getWorkerScannerLogger(self):
+        """Return the logger instance from lp.buildmaster.manager."""
         # XXX cprov 20071120: Ideally the Launchpad logging system
         # should be able to configure the root-logger instead of creating
         # a new object, then the logger lookups won't require the specific
         # name argument anymore. See bug 164203.
-        logger = logging.getLogger('slave-scanner')
+        logger = logging.getLogger('worker-scanner')
         return logger
 
     def findBuildCandidates(self, processor, virtualized, limit):
@@ -304,7 +304,7 @@ class BuildQueueSet:
         # Circular import.
         from lp.buildmaster.model.buildfarmjob import BuildFarmJob
 
-        logger = self._getSlaveScannerLogger()
+        logger = self._getWorkerScannerLogger()
 
         job_type_conditions = []
         job_sources = specific_build_farm_job_sources()
diff --git a/lib/lp/buildmaster/tests/test_buildqueue.py b/lib/lp/buildmaster/tests/test_buildqueue.py
index 36c338f..5b41e41 100644
--- a/lib/lp/buildmaster/tests/test_buildqueue.py
+++ b/lib/lp/buildmaster/tests/test_buildqueue.py
@@ -72,8 +72,8 @@ class TestBuildCancellation(TestCaseWithFactory):
 
     def test_buildqueue_cancel_running(self):
         # Cancelling a RUNNING BuildQueue leaves it around but sets the
-        # status to CANCELLING. SlaveScanner will destroy it and set the
-        # build status to CANCELLED when the slave cancellation has
+        # status to CANCELLING. WorkerScanner will destroy it and set the
+        # build status to CANCELLED when the worker cancellation has
         # completed.
         build = self.factory.makeBinaryPackageBuild()
         bq = build.queueBuild()
diff --git a/lib/lp/buildmaster/tests/test_manager.py b/lib/lp/buildmaster/tests/test_manager.py
index 24814bd..705389e 100644
--- a/lib/lp/buildmaster/tests/test_manager.py
+++ b/lib/lp/buildmaster/tests/test_manager.py
@@ -1,7 +1,7 @@
 # Copyright 2009-2021 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
-"""Tests for the renovated slave scanner aka BuilddManager."""
+"""Tests for the renovated worker scanner aka BuilddManager."""
 
 import os
 import signal
@@ -48,7 +48,7 @@ from lp.buildmaster.manager import (
     judge_failure,
     PrefetchedBuilderFactory,
     recover_failure,
-    SlaveScanner,
+    WorkerScanner,
     )
 from lp.buildmaster.tests.harness import BuilddManagerTestSetup
 from lp.buildmaster.tests.mock_workers import (
@@ -92,8 +92,8 @@ from lp.testing.matchers import HasQueryCount
 from lp.testing.sampledata import BOB_THE_BUILDER_NAME
 
 
-class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
-    """Tests `SlaveScanner.scan` method.
+class TestWorkerScannerScan(StatsMixin, TestCaseWithFactory):
+    """Tests `WorkerScanner.scan` method.
 
     This method uses the old framework for scanning and dispatching builds.
     """
@@ -140,7 +140,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
         self.assertEqual(job.logtail, logtail)
 
     def _getScanner(self, builder_name=None, clock=None, builder_factory=None):
-        """Instantiate a SlaveScanner object.
+        """Instantiate a WorkerScanner object.
 
         Replace its default logging handler by a testing version.
         """
@@ -150,10 +150,10 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
             builder_factory = BuilderFactory()
         manager = BuilddManager(builder_factory=builder_factory, clock=clock)
         manager.logger = BufferLogger()
-        scanner = SlaveScanner(
+        scanner = WorkerScanner(
             builder_name, builder_factory, manager, BufferLogger(),
             clock=clock)
-        scanner.logger.name = 'slave-scanner'
+        scanner.logger.name = 'worker-scanner'
 
         return scanner
 
@@ -184,7 +184,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
         self.assertTrue(builder.currentjob is None)
 
     def _checkJobRescued(self, builder, job):
-        """`SlaveScanner.scan` rescued the job.
+        """`WorkerScanner.scan` rescued the job.
 
         Nothing gets dispatched,  the 'broken' builder remained disabled
         and the 'rescued' job is ready to be dispatched.
@@ -224,7 +224,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
         self._checkJobRescued(builder, job)
 
     def _checkJobUpdated(self, builder, job, logtail='This is a build log: 0'):
-        """`SlaveScanner.scan` updates legitimate jobs.
+        """`WorkerScanner.scan` updates legitimate jobs.
 
         Job is kept assigned to the active builder and its 'logtail' is
         updated.
@@ -238,7 +238,7 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
     @defer.inlineCallbacks
     def testScanUpdatesBuildingJobs(self):
         # Enable sampledata builder attached to an appropriate testing
-        # slave. It will respond as if it was building the sampledata job.
+        # worker. It will respond as if it was building the sampledata job.
         builder = getUtility(IBuilderSet)[BOB_THE_BUILDER_NAME]
 
         login('foo.bar@xxxxxxxxxxxxx')
@@ -366,14 +366,14 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
 
     @defer.inlineCallbacks
     def test_scan_calls_builder_factory_prescanUpdate(self):
-        # SlaveScanner.scan() starts by calling
+        # WorkerScanner.scan() starts by calling
         # BuilderFactory.prescanUpdate() to eg. perform necessary
         # transaction management.
         bf = BuilderFactory()
         bf.prescanUpdate = FakeMethod()
         scanner = self._getScanner(builder_factory=bf)
 
-        # Disable the builder so we don't try to use the slave. It's not
+        # Disable the builder so we don't try to use the worker. It's not
         # relevant for this test.
         builder = getUtility(IBuilderSet)[BOB_THE_BUILDER_NAME]
         builder.builderok = False
@@ -657,14 +657,14 @@ class TestSlaveScannerScan(StatsMixin, TestCaseWithFactory):
         # Advance past the timeout.  The build state should be cancelled and
         # we should have also called the resume() method on the worker that
         # resets the virtual machine.
-        clock.advance(SlaveScanner.CANCEL_TIMEOUT)
+        clock.advance(WorkerScanner.CANCEL_TIMEOUT)
         yield scanner.singleCycle()
         self.assertEqual(1, worker.call_log.count("abort"))
         self.assertEqual(BuilderCleanStatus.DIRTY, builder.clean_status)
         self.assertEqual(BuildStatus.CANCELLED, build.status)
 
 
-class TestSlaveScannerWithLibrarian(TestCaseWithFactory):
+class TestWorkerScannerWithLibrarian(TestCaseWithFactory):
 
     layer = LaunchpadZopelessLayer
     run_tests_with = AsynchronousDeferredRunTest.make_factory(timeout=20)
@@ -675,7 +675,7 @@ class TestSlaveScannerWithLibrarian(TestCaseWithFactory):
 
     @defer.inlineCallbacks
     def test_end_to_end(self):
-        # Test that SlaveScanner.scan() successfully finds, dispatches,
+        # Test that WorkerScanner.scan() successfully finds, dispatches,
         # collects and cleans a build, and then makes a reasonable start on
         # a second build.
         build = self.factory.makeBinaryPackageBuild()
@@ -699,15 +699,15 @@ class TestSlaveScannerWithLibrarian(TestCaseWithFactory):
         self.patch(
             BinaryPackageBuildBehaviour, 'handleSuccess', handleSuccess)
 
-        # And create a SlaveScanner with a slave and a clock that we
+        # And create a WorkerScanner with a worker and a clock that we
         # control.
         get_worker = FakeMethod(OkWorker())
         clock = task.Clock()
         manager = BuilddManager(clock=clock)
         manager.logger = BufferLogger()
-        scanner = SlaveScanner(
+        scanner = WorkerScanner(
             builder.name, BuilderFactory(), manager, BufferLogger(),
-            slave_factory=get_worker, clock=clock)
+            worker_factory=get_worker, clock=clock)
 
         # The worker is idle and dirty, so the first scan will clean it
         # with a reset.
@@ -923,7 +923,7 @@ class FakeBuilddManager:
         self.pending_logtails[build_queue_id] = logtail
 
 
-class TestSlaveScannerWithoutDB(TestCase):
+class TestWorkerScannerWithoutDB(TestCase):
 
     layer = ZopelessDatabaseLayer
     run_tests_with = AsynchronousDeferredRunTest
@@ -944,15 +944,15 @@ class TestSlaveScannerWithoutDB(TestCase):
             worker = OkWorker()
         if behaviour is None:
             behaviour = TrivialBehaviour()
-        return SlaveScanner(
+        return WorkerScanner(
             'mock', builder_factory, FakeBuilddManager(), BufferLogger(),
             interactor_factory=FakeMethod(interactor),
-            slave_factory=FakeMethod(worker),
+            worker_factory=FakeMethod(worker),
             behaviour_factory=FakeMethod(behaviour))
 
     @defer.inlineCallbacks
     def test_scan_with_job(self):
-        # SlaveScanner.scan calls updateBuild() when a job is building.
+        # WorkerScanner.scan calls updateBuild() when a job is building.
         worker = BuildingWorker('trivial')
         bq = FakeBuildQueue('trivial')
         scanner = self.getScanner(
@@ -967,7 +967,7 @@ class TestSlaveScannerWithoutDB(TestCase):
 
     @defer.inlineCallbacks
     def test_scan_recovers_lost_worker_with_job(self):
-        # SlaveScanner.scan identifies workers that aren't building what
+        # WorkerScanner.scan identifies workers that aren't building what
         # they should be, resets the jobs, and then aborts the workers.
         worker = BuildingWorker('nontrivial')
         bq = FakeBuildQueue('trivial')
@@ -993,7 +993,7 @@ class TestSlaveScannerWithoutDB(TestCase):
 
     @defer.inlineCallbacks
     def test_scan_recovers_lost_worker_when_idle(self):
-        # SlaveScanner.scan identifies workers that are building when
+        # WorkerScanner.scan identifies workers that are building when
         # they shouldn't be and aborts them.
         worker = BuildingWorker()
         scanner = self.getScanner(worker=worker)
@@ -1037,10 +1037,10 @@ class TestSlaveScannerWithoutDB(TestCase):
         bf = MockBuilderFactory(MockBuilder(), bq)
         manager = BuilddManager()
         manager.logger = BufferLogger()
-        scanner = SlaveScanner(
+        scanner = WorkerScanner(
             'mock', bf, manager, BufferLogger(),
             interactor_factory=FakeMethod(None),
-            slave_factory=FakeMethod(None),
+            worker_factory=FakeMethod(None),
             behaviour_factory=FakeMethod(TrivialBehaviour()))
 
         # The first call retrieves the cookie from the BuildQueue.
@@ -1136,9 +1136,9 @@ class TestCancellationChecking(TestCaseWithFactory):
     def _getScanner(self, clock=None):
         manager = BuilddManager(clock=clock)
         manager.logger = BufferLogger()
-        scanner = SlaveScanner(
+        scanner = WorkerScanner(
             None, BuilderFactory(), manager, BufferLogger(), clock=clock)
-        scanner.logger.name = 'slave-scanner'
+        scanner.logger.name = 'worker-scanner'
         return scanner
 
     def test_ignores_build_not_cancelling(self):
@@ -1177,7 +1177,7 @@ class TestCancellationChecking(TestCaseWithFactory):
         self.assertEqual(["abort"], worker.call_log)
         self.assertEqual(BuildStatus.CANCELLING, build.status)
 
-        clock.advance(SlaveScanner.CANCEL_TIMEOUT)
+        clock.advance(WorkerScanner.CANCEL_TIMEOUT)
         with ExpectedException(
                 BuildSlaveFailure, "Timeout waiting for .* to cancel"):
             yield scanner.checkCancellation(self.vitals, worker)
@@ -1200,10 +1200,10 @@ class TestBuilddManager(TestCase):
     def _stub_out_scheduleNextScanCycle(self):
         # stub out the code that adds a callLater, so that later tests
         # don't get surprises.
-        self.patch(SlaveScanner, 'startCycle', FakeMethod())
+        self.patch(WorkerScanner, 'startCycle', FakeMethod())
 
     def test_addScanForBuilders(self):
-        # Test that addScanForBuilders generates SlaveScanner objects.
+        # Test that addScanForBuilders generates WorkerScanner objects.
         self._stub_out_scheduleNextScanCycle()
 
         manager = BuilddManager()