launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23298
[Merge] lp:~cjwatson/launchpad/dispatch-with-lxd-images into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/dispatch-with-lxd-images into lp:launchpad.
Commit message:
Prefer LXD images when dispatching livefs and snap builds.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1811677 in Launchpad itself: "Allow dispatching livefs and snap builds based on LXD images"
https://bugs.launchpad.net/launchpad/+bug/1811677
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/dispatch-with-lxd-images/+merge/362883
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/dispatch-with-lxd-images into lp:launchpad.
=== modified file 'lib/lp/snappy/model/snapbuildbehaviour.py'
--- lib/lp/snappy/model/snapbuildbehaviour.py 2019-01-07 17:15:28 +0000
+++ lib/lp/snappy/model/snapbuildbehaviour.py 2019-02-07 19:44:23 +0000
@@ -20,6 +20,7 @@
from zope.interface import implementer
from zope.security.proxy import removeSecurityProxy
+from lp.buildmaster.enums import BuildBaseImageType
from lp.buildmaster.interfaces.builder import CannotBuild
from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
IBuildFarmJobBehaviour,
@@ -48,6 +49,7 @@
"""Dispatches `SnapBuild` jobs to slaves."""
builder_type = "snap"
+ image_types = [BuildBaseImageType.LXD, BuildBaseImageType.CHROOT]
def getLogFileName(self):
das = self.build.distro_arch_series
=== modified file 'lib/lp/snappy/tests/test_snapbuildbehaviour.py'
--- lib/lp/snappy/tests/test_snapbuildbehaviour.py 2019-01-07 17:15:28 +0000
+++ lib/lp/snappy/tests/test_snapbuildbehaviour.py 2019-02-07 19:44:23 +0000
@@ -53,7 +53,10 @@
from lp.archivepublisher.interfaces.archivesigningkey import (
IArchiveSigningKey,
)
-from lp.buildmaster.enums import BuildStatus
+from lp.buildmaster.enums import (
+ BuildBaseImageType,
+ BuildStatus,
+ )
from lp.buildmaster.interfaces.builder import CannotBuild
from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
IBuildFarmJobBehaviour,
@@ -73,7 +76,10 @@
from lp.registry.interfaces.series import SeriesStatus
from lp.services.config import config
from lp.services.features.testing import FeatureFixture
-from lp.services.log.logger import BufferLogger
+from lp.services.log.logger import (
+ BufferLogger,
+ DevNullLogger,
+ )
from lp.services.webapp import canonical_url
from lp.snappy.interfaces.snap import (
SNAP_SNAPCRAFT_CHANNEL_FEATURE_FLAG,
@@ -630,6 +636,37 @@
with ExpectedException(CannotBuild, expected_exception_msg):
yield job.composeBuildRequest(None)
+ @defer.inlineCallbacks
+ def test_dispatchBuildToSlave_prefers_lxd(self):
+ job = self.makeJob(allow_internet=False)
+ builder = MockBuilder()
+ builder.processor = job.build.processor
+ slave = OkSlave()
+ job.setBuilder(builder, slave)
+ chroot_lfa = self.factory.makeLibraryFileAlias(db_only=True)
+ job.build.distro_arch_series.addOrUpdateChroot(
+ chroot_lfa, image_type=BuildBaseImageType.CHROOT)
+ lxd_lfa = self.factory.makeLibraryFileAlias(db_only=True)
+ job.build.distro_arch_series.addOrUpdateChroot(
+ lxd_lfa, image_type=BuildBaseImageType.LXD)
+ yield job.dispatchBuildToSlave(DevNullLogger())
+ self.assertEqual(
+ ('ensurepresent', lxd_lfa.http_url, '', ''), slave.call_log[0])
+
+ @defer.inlineCallbacks
+ def test_dispatchBuildToSlave_falls_back_to_chroot(self):
+ job = self.makeJob(allow_internet=False)
+ builder = MockBuilder()
+ builder.processor = job.build.processor
+ slave = OkSlave()
+ job.setBuilder(builder, slave)
+ chroot_lfa = self.factory.makeLibraryFileAlias(db_only=True)
+ job.build.distro_arch_series.addOrUpdateChroot(
+ chroot_lfa, image_type=BuildBaseImageType.CHROOT)
+ yield job.dispatchBuildToSlave(DevNullLogger())
+ self.assertEqual(
+ ('ensurepresent', chroot_lfa.http_url, '', ''), slave.call_log[0])
+
class MakeSnapBuildMixin:
"""Provide the common makeBuild method returning a queued build."""
=== modified file 'lib/lp/soyuz/model/livefsbuildbehaviour.py'
--- lib/lp/soyuz/model/livefsbuildbehaviour.py 2019-01-07 17:15:28 +0000
+++ lib/lp/soyuz/model/livefsbuildbehaviour.py 2019-02-07 19:44:23 +0000
@@ -16,6 +16,7 @@
from zope.interface import implementer
from zope.security.proxy import removeSecurityProxy
+from lp.buildmaster.enums import BuildBaseImageType
from lp.buildmaster.interfaces.builder import CannotBuild
from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
IBuildFarmJobBehaviour,
@@ -38,6 +39,7 @@
"""Dispatches `LiveFSBuild` jobs to slaves."""
builder_type = "livefs"
+ image_types = [BuildBaseImageType.LXD, BuildBaseImageType.CHROOT]
def getLogFileName(self):
das = self.build.distro_arch_series
=== modified file 'lib/lp/soyuz/tests/test_livefsbuildbehaviour.py'
--- lib/lp/soyuz/tests/test_livefsbuildbehaviour.py 2019-01-07 17:15:28 +0000
+++ lib/lp/soyuz/tests/test_livefsbuildbehaviour.py 2019-02-07 19:44:23 +0000
@@ -23,7 +23,10 @@
from lp.archivepublisher.interfaces.archivesigningkey import (
IArchiveSigningKey,
)
-from lp.buildmaster.enums import BuildStatus
+from lp.buildmaster.enums import (
+ BuildBaseImageType,
+ BuildStatus,
+ )
from lp.buildmaster.interfaces.builder import CannotBuild
from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
IBuildFarmJobBehaviour,
@@ -41,7 +44,10 @@
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.registry.interfaces.series import SeriesStatus
from lp.services.features.testing import FeatureFixture
-from lp.services.log.logger import BufferLogger
+from lp.services.log.logger import (
+ BufferLogger,
+ DevNullLogger,
+ )
from lp.services.webapp import canonical_url
from lp.soyuz.adapters.archivedependencies import (
get_sources_list_for_building,
@@ -276,6 +282,37 @@
args),
build_request)
+ @defer.inlineCallbacks
+ def test_dispatchBuildToSlave_prefers_lxd(self):
+ job = self.makeJob()
+ builder = MockBuilder()
+ builder.processor = job.build.processor
+ slave = OkSlave()
+ job.setBuilder(builder, slave)
+ chroot_lfa = self.factory.makeLibraryFileAlias(db_only=True)
+ job.build.distro_arch_series.addOrUpdateChroot(
+ chroot_lfa, image_type=BuildBaseImageType.CHROOT)
+ lxd_lfa = self.factory.makeLibraryFileAlias(db_only=True)
+ job.build.distro_arch_series.addOrUpdateChroot(
+ lxd_lfa, image_type=BuildBaseImageType.LXD)
+ yield job.dispatchBuildToSlave(DevNullLogger())
+ self.assertEqual(
+ ('ensurepresent', lxd_lfa.http_url, '', ''), slave.call_log[0])
+
+ @defer.inlineCallbacks
+ def test_dispatchBuildToSlave_falls_back_to_chroot(self):
+ job = self.makeJob()
+ builder = MockBuilder()
+ builder.processor = job.build.processor
+ slave = OkSlave()
+ job.setBuilder(builder, slave)
+ chroot_lfa = self.factory.makeLibraryFileAlias(db_only=True)
+ job.build.distro_arch_series.addOrUpdateChroot(
+ chroot_lfa, image_type=BuildBaseImageType.CHROOT)
+ yield job.dispatchBuildToSlave(DevNullLogger())
+ self.assertEqual(
+ ('ensurepresent', chroot_lfa.http_url, '', ''), slave.call_log[0])
+
class MakeLiveFSBuildMixin:
"""Provide the common makeBuild method returning a queued build."""
Follow ups