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
diff --git a/lib/lp/oci/model/ocirecipebuildjob.py b/lib/lp/oci/model/ocirecipebuildjob.py
index 1e4a7e8..20337c1 100644
--- a/lib/lp/oci/model/ocirecipebuildjob.py
+++ b/lib/lp/oci/model/ocirecipebuildjob.py
@@ -351,15 +351,6 @@ class OCIRegistryUploadJob(OCIRecipeBuildJobDerived):
351 self.build_uploaded = True351 self.build_uploaded = True
352352
353 self.uploadManifestList(client)353 self.uploadManifestList(client)
354 # Force this job status to COMPLETED in the same transaction we
355 # called `getUploadedBuilds` (in the uploadManifestList call
356 # above) to release the lock already including our new status.
357 # This way, any other transaction that was blocked waiting to
358 # get the info about the upload jobs will immediately have the
359 # new status of this job, avoiding race conditions. Keep the
360 # `manage_transaction=False` to prevent the method from
361 # commiting at the wrong moment.
362 self.complete(manage_transaction=False)
363354
364 except OCIRegistryError as e:355 except OCIRegistryError as e:
365 self.error_summary = str(e)356 self.error_summary = str(e)
diff --git a/lib/lp/oci/tests/test_ocirecipebuildjob.py b/lib/lp/oci/tests/test_ocirecipebuildjob.py
index 59554e6..478eb6a 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildjob.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildjob.py
@@ -566,6 +566,26 @@ class TestOCIRegistryUploadJob(TestCaseWithFactory, MultiArchRecipeMixin,
566 self.assertWebhookDeliveries(566 self.assertWebhookDeliveries(
567 ocibuild, ["Pending", "Failed to upload"], logger)567 ocibuild, ["Pending", "Failed to upload"], logger)
568568
569 def test_run_does_not_oops(self):
570 # The job can OOPS, but it is hidden by our exception handling
571 # Check that it's actually empty
572 build_request = self.makeBuildRequest(include_i386=False)
573 recipe = build_request.recipe
574
575 self.assertEqual(1, build_request.builds.count())
576 ocibuild = build_request.builds[0]
577 ocibuild.updateStatus(BuildStatus.FULLYBUILT)
578 self.makeWebhook(recipe)
579
580 self.assertContentEqual([], ocibuild.registry_upload_jobs)
581 job = OCIRegistryUploadJob.create(ocibuild)
582 client = FakeRegistryClient()
583 self.useFixture(ZopeUtilityFixture(client, IOCIRegistryClient))
584 with dbuser(config.IOCIRegistryUploadJobSource.dbuser):
585 run_isolated_jobs([job])
586
587 self.assertEqual(0, len(self.oopses))
588
569589
570class TestOCIRegistryUploadJobViaCelery(TestCaseWithFactory,590class TestOCIRegistryUploadJobViaCelery(TestCaseWithFactory,
571 MultiArchRecipeMixin):591 MultiArchRecipeMixin):

Subscribers

People subscribed via source and target branches

to status/vote changes: