Merge ~twom/launchpad:oci-remove-unnecessary-complete into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 4d8ee6bdaaa78fbcf1e9cd13158e52ca78f7dbb2
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:oci-remove-unnecessary-complete
Merge into: launchpad:master
Diff against target: 51 lines (+20/-9)
2 files modified
lib/lp/oci/model/ocirecipebuildjob.py (+0/-9)
lib/lp/oci/tests/test_ocirecipebuildjob.py (+20/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+399312@code.launchpad.net

Commit message

Remove first complete from OCIRegistryUploadJob

Description of the change

This complete appears to be masking failures, and is causing unnecessary OOPS on all RegistryUpload jobs as it causes an invalid transition of Complete -> Complete.

Without managing the transaction, this also appears to be unnecessary?

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/oci/model/ocirecipebuildjob.py b/lib/lp/oci/model/ocirecipebuildjob.py
2index 1e4a7e8..20337c1 100644
3--- a/lib/lp/oci/model/ocirecipebuildjob.py
4+++ b/lib/lp/oci/model/ocirecipebuildjob.py
5@@ -351,15 +351,6 @@ class OCIRegistryUploadJob(OCIRecipeBuildJobDerived):
6 self.build_uploaded = True
7
8 self.uploadManifestList(client)
9- # Force this job status to COMPLETED in the same transaction we
10- # called `getUploadedBuilds` (in the uploadManifestList call
11- # above) to release the lock already including our new status.
12- # This way, any other transaction that was blocked waiting to
13- # get the info about the upload jobs will immediately have the
14- # new status of this job, avoiding race conditions. Keep the
15- # `manage_transaction=False` to prevent the method from
16- # commiting at the wrong moment.
17- self.complete(manage_transaction=False)
18
19 except OCIRegistryError as e:
20 self.error_summary = str(e)
21diff --git a/lib/lp/oci/tests/test_ocirecipebuildjob.py b/lib/lp/oci/tests/test_ocirecipebuildjob.py
22index 59554e6..478eb6a 100644
23--- a/lib/lp/oci/tests/test_ocirecipebuildjob.py
24+++ b/lib/lp/oci/tests/test_ocirecipebuildjob.py
25@@ -566,6 +566,26 @@ class TestOCIRegistryUploadJob(TestCaseWithFactory, MultiArchRecipeMixin,
26 self.assertWebhookDeliveries(
27 ocibuild, ["Pending", "Failed to upload"], logger)
28
29+ def test_run_does_not_oops(self):
30+ # The job can OOPS, but it is hidden by our exception handling
31+ # Check that it's actually empty
32+ build_request = self.makeBuildRequest(include_i386=False)
33+ recipe = build_request.recipe
34+
35+ self.assertEqual(1, build_request.builds.count())
36+ ocibuild = build_request.builds[0]
37+ ocibuild.updateStatus(BuildStatus.FULLYBUILT)
38+ self.makeWebhook(recipe)
39+
40+ self.assertContentEqual([], ocibuild.registry_upload_jobs)
41+ job = OCIRegistryUploadJob.create(ocibuild)
42+ client = FakeRegistryClient()
43+ self.useFixture(ZopeUtilityFixture(client, IOCIRegistryClient))
44+ with dbuser(config.IOCIRegistryUploadJobSource.dbuser):
45+ run_isolated_jobs([job])
46+
47+ self.assertEqual(0, len(self.oopses))
48+
49
50 class TestOCIRegistryUploadJobViaCelery(TestCaseWithFactory,
51 MultiArchRecipeMixin):

Subscribers

People subscribed via source and target branches

to status/vote changes: