launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #12099
[Merge] lp:~stevenk/launchpad/destroy-bfj-on-branch-delete into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/destroy-bfj-on-branch-delete into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1019218 in Launchpad itself: "InconsistentBuildFarmJobError: Could not find all the related specific jobs at Builder:+history"
https://bugs.launchpad.net/launchpad/+bug/1019218
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/destroy-bfj-on-branch-delete/+merge/124828
Branch._deleteJobs() made the assumption that ON DELETE CASCADE would remove all references to the TTB that was being deleted. Which will remove everything but the BuildFarmJob. So delete that, and add a test that makes sure Builder:+history deals with it.
--
https://code.launchpad.net/~stevenk/launchpad/destroy-bfj-on-branch-delete/+merge/124828
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/destroy-bfj-on-branch-delete into lp:launchpad.
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2012-09-14 01:21:13 +0000
+++ lib/lp/code/model/branch.py 2012-09-18 01:06:22 +0000
@@ -65,6 +65,7 @@
from lp.bugs.interfaces.bugtask import IBugTaskSet
from lp.bugs.interfaces.bugtaskfilter import filter_bugtasks_by_context
from lp.bugs.interfaces.bugtasksearch import BugTaskSearchParams
+from lp.buildmaster.model.buildfarmjob import BuildFarmJob
from lp.buildmaster.model.buildqueue import BuildQueue
from lp.code.bzr import (
BranchFormat,
@@ -1252,12 +1253,20 @@
# the affected Jobs in the database otherwise.
store.find(BuildQueue, BuildQueue.jobID.is_in(affected_jobs)).remove()
+ # Find BuildFarmJobs to delete.
+ bfjs = store.find(
+ BuildFarmJob,
+ TranslationTemplatesBuild.build_farm_job_id == BuildFarmJob.id,
+ TranslationTemplatesBuild.branch == self)
+ bfj_ids = [bfj.id for bfj in bfjs]
+
# Delete Jobs. Their BranchJobs cascade along in the database.
store.find(Job, Job.id.is_in(affected_jobs)).remove()
store.find(
TranslationTemplatesBuild,
TranslationTemplatesBuild.branch == self).remove()
+ store.find(BuildFarmJob, BuildFarmJob.id.is_in(bfj_ids)).remove()
def destroySelf(self, break_references=False):
"""See `IBranch`."""
=== modified file 'lib/lp/soyuz/browser/tests/test_builder_views.py'
--- lib/lp/soyuz/browser/tests/test_builder_views.py 2012-01-04 16:55:27 +0000
+++ lib/lp/soyuz/browser/tests/test_builder_views.py 2012-09-18 01:06:22 +0000
@@ -307,3 +307,10 @@
self.assertThat(
view.render(),
MatchesAll(private_build_matcher, private_build_icon_matcher))
+
+ def test_build_history_with_ttbj_on_deleted_branch(self):
+ build = self.createTranslationTemplateBuildWithBuilder(
+ builder=self.builder)
+ removeSecurityProxy(build.branch)._deleteJobs()
+ view = create_initialized_view(self.builder, '+history')
+ self.assertIn('No build records.', view.render())
Follow ups