launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29583
[Merge] ~cjwatson/launchpad:ci-recalculate-builder-constraints into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:ci-recalculate-builder-constraints into launchpad:master.
Commit message:
Recalculate CIBuild.builder_constraints on retry
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/436200
This allows us to reconfigure a repository's builder constraints and then just retry builds, rather than having to push new commits to cause new builds to be created.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:ci-recalculate-builder-constraints into launchpad:master.
diff --git a/lib/lp/code/model/cibuild.py b/lib/lp/code/model/cibuild.py
index d431000..0bfc773 100644
--- a/lib/lp/code/model/cibuild.py
+++ b/lib/lp/code/model/cibuild.py
@@ -310,6 +310,13 @@ class CIBuild(PackageBuildMixin, StormBase):
return False
return super().can_be_retried
+ def resetBuild(self):
+ """See `IBuildFarmJob`."""
+ super().resetBuild()
+ self.builder_constraints = copy(
+ removeSecurityProxy(self.git_repository.builder_constraints)
+ )
+
def calculateScore(self):
# Low latency is especially useful for CI builds, so score these
# above bulky things like live filesystem builds, but below
diff --git a/lib/lp/code/model/tests/test_cibuild.py b/lib/lp/code/model/tests/test_cibuild.py
index 114b606..6211bc4 100644
--- a/lib/lp/code/model/tests/test_cibuild.py
+++ b/lib/lp/code/model/tests/test_cibuild.py
@@ -68,6 +68,7 @@ from lp.testing import (
StormStatementRecorder,
TestCaseWithFactory,
api_url,
+ celebrity_logged_in,
login,
logout,
person_logged_in,
@@ -240,6 +241,20 @@ class TestCIBuild(TestCaseWithFactory):
self.assertIsNone(build.upload_log)
self.assertEqual(0, build.failure_count)
+ def test_retry_resets_builder_constraints(self):
+ # Retrying a build recalculates its builder constraints.
+ build = self.factory.makeCIBuild()
+ self.assertIsNone(build.builder_constraints)
+ build.updateStatus(BuildStatus.BUILDING)
+ build.updateStatus(BuildStatus.FAILEDTOBUILD)
+ build.gotFailure()
+ with celebrity_logged_in("commercial_admin"):
+ build.git_repository.builder_constraints = ["gpu"]
+ with person_logged_in(build.git_repository.owner):
+ build.retry()
+ self.assertEqual(BuildStatus.NEEDSBUILD, build.status)
+ self.assertEqual(("gpu",), build.builder_constraints)
+
def test_cancel_not_in_progress(self):
# The cancel() method for a pending build leaves it in the CANCELLED
# state.