launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26436
[Merge] ~pappacena/launchpad:oci-recipe-cascade-delete-bugfix into launchpad:master
Thiago F. Pappacena has proposed merging ~pappacena/launchpad:oci-recipe-cascade-delete-bugfix into launchpad:master.
Commit message:
Fixing cascading deletion problem on OCIRecipe (bug #1916605)
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1916605 in Launchpad itself: "Cannot delete OCI recipes"
https://bugs.launchpad.net/launchpad/+bug/1916605
For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/398711
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:oci-recipe-cascade-delete-bugfix into launchpad:master.
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index 28ce8a0..e4edcae 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -1,4 +1,4 @@
-# Copyright 2019-2020 Canonical Ltd. This software is licensed under the
+# Copyright 2019-2021 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""A recipe for building Open Container Initiative images."""
@@ -253,9 +253,9 @@ class OCIRecipe(Storm, WebhookTargetMixin):
affected_jobs = Select(
[OCIRecipeJob.job_id],
And(OCIRecipeJob.job == Job.id, OCIRecipeJob.recipe == self))
- store.find(Job, Job.id.is_in(affected_jobs)).remove()
builds = store.find(OCIRecipeBuild, OCIRecipeBuild.recipe == self)
builds.remove()
+ store.find(Job, Job.id.is_in(affected_jobs)).remove()
for push_rule in self.push_rules:
push_rule.destroySelf()
getUtility(IWebhookSet).delete(self.webhooks)
diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
index 3486d57..5335baa 100644
--- a/lib/lp/oci/tests/test_ocirecipe.py
+++ b/lib/lp/oci/tests/test_ocirecipe.py
@@ -1,4 +1,4 @@
-# Copyright 2019-2020 Canonical Ltd. This software is licensed under the
+# Copyright 2019-2021 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests for OCI image building recipe functionality."""
@@ -391,8 +391,10 @@ class TestOCIRecipe(OCIConfigHelperMixin, TestCaseWithFactory):
self.setConfig()
oci_recipe = self.factory.makeOCIRecipe()
# Create associated builds:
+ build_request = oci_recipe.requestBuilds(oci_recipe.owner, ["386"])
build_ids = [
- self.factory.makeOCIRecipeBuild(recipe=oci_recipe).id
+ self.factory.makeOCIRecipeBuild(
+ recipe=oci_recipe, build_request=build_request).id
for _ in range(3)]
# Create associated push rules:
push_rule_ids = [
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 8577727..9661a8f 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -2,7 +2,7 @@
# NOTE: The first line above must stay first; do not move the copyright
# notice to the top. See http://www.python.org/dev/peps/pep-0263/.
#
-# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2021 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Testing infrastructure for the Launchpad application.
@@ -4985,7 +4985,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
def makeOCIRecipeBuild(self, requester=None, registrant=None, recipe=None,
distro_arch_series=None, date_created=DEFAULT,
status=BuildStatus.NEEDSBUILD, builder=None,
- duration=None, **kwargs):
+ duration=None, build_request=None, **kwargs):
"""Make a new OCIRecipeBuild."""
if requester is None:
requester = self.makePerson()
@@ -5008,7 +5008,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
recipe = self.makeOCIRecipe(
registrant=registrant, oci_project=oci_project, **kwargs)
oci_build = getUtility(IOCIRecipeBuildSet).new(
- requester, recipe, distro_arch_series, date_created)
+ requester, recipe, distro_arch_series, date_created, build_request)
if duration is not None:
removeSecurityProxy(oci_build).updateStatus(
BuildStatus.BUILDING, builder=builder,
Follow ups