← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:bugfix-snap-completed-builds-timeout into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:bugfix-snap-completed-builds-timeout into launchpad:master.

Commit message:
Pre-fetching Builder objects on Snap._getBuilds.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1901566 in Launchpad itself: "timeout from api.launchpad.net for snap build status"
  https://bugs.launchpad.net/launchpad/+bug/1901566

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/392790
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:bugfix-snap-completed-builds-timeout into launchpad:master.
diff --git a/lib/lp/snappy/model/snap.py b/lib/lp/snappy/model/snap.py
index aa147ef..1ef8f45 100644
--- a/lib/lp/snappy/model/snap.py
+++ b/lib/lp/snappy/model/snap.py
@@ -58,6 +58,7 @@ from lp.app.errors import IncompatibleArguments
 from lp.app.interfaces.security import IAuthorization
 from lp.buildmaster.enums import BuildStatus
 from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet
+from lp.buildmaster.model.builder import Builder
 from lp.buildmaster.model.buildfarmjob import BuildFarmJob
 from lp.buildmaster.model.buildqueue import BuildQueue
 from lp.buildmaster.model.processor import Processor
@@ -878,6 +879,7 @@ class Snap(Storm, WebhookTargetMixin):
         def eager_load(rows):
             getUtility(ISnapBuildSet).preloadBuildsData(rows)
             getUtility(IBuildQueueSet).preloadForBuildFarmJobs(rows)
+            load_related(Builder, rows, ['builder_id'])
 
         return DecoratedResultSet(result, pre_iter_hook=eager_load)
 
diff --git a/lib/lp/snappy/tests/test_snap.py b/lib/lp/snappy/tests/test_snap.py
index 8c87c8a..b3b6bc5 100644
--- a/lib/lp/snappy/tests/test_snap.py
+++ b/lib/lp/snappy/tests/test_snap.py
@@ -3936,6 +3936,7 @@ class TestSnapWebservice(TestCaseWithFactory):
 
         def make_build():
             with person_logged_in(self.person):
+                builder = self.factory.makeBuilder()
                 build = snap.requestBuild(
                     self.person, distroseries.main_archive, distroarchseries,
                     PackagePublishingPocket.PROPOSED)
@@ -3944,6 +3945,7 @@ class TestSnapWebservice(TestCaseWithFactory):
                         BuildStatus.BUILDING, date_started=snap.date_created)
                     build.updateStatus(
                         BuildStatus.FULLYBUILT,
+                        builder=builder,
                         date_finished=(
                             snap.date_created + timedelta(minutes=10)))
                 return build