Merge ~twom/launchpad:oci-retry-timeout-uploads into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 29805d098ea267fa285a930ef293c59cdd40c86c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:oci-retry-timeout-uploads
Merge into: launchpad:master
Diff against target: 116 lines (+31/-14)
3 files modified
lib/lp/oci/model/ocirecipebuildjob.py (+8/-4)
lib/lp/oci/tests/test_ocirecipebuildjob.py (+5/-10)
lib/lp/testing/layers.py (+18/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+402266@code.launchpad.net

Commit message

Move RegistryUpload to the slow queue

Description of the change

RegistryUpload can regularly exceed the 300 seconds for a job in the normal job queue. The fallback to the slow queue doesn't appear to work correctly, so for now, just use the slow queue directly.

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

LGTM

review: Approve
29805d0... by Tom Wardill

Increase per-task lease and soft timeout

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 8f55850..9ec2e91 100644
3--- a/lib/lp/oci/model/ocirecipebuildjob.py
4+++ b/lib/lp/oci/model/ocirecipebuildjob.py
5@@ -45,10 +45,7 @@ from lp.oci.interfaces.ociregistryclient import (
6 )
7 from lp.services.config import config
8 from lp.services.database.enumcol import DBEnum
9-from lp.services.database.interfaces import (
10- IMasterStore,
11- IStore,
12- )
13+from lp.services.database.interfaces import IStore
14 from lp.services.database.locking import (
15 AdvisoryLockHeld,
16 LockType,
17@@ -189,6 +186,13 @@ class OCIRegistryUploadJob(OCIRecipeBuildJobDerived):
18
19 class_job_type = OCIRecipeBuildJobType.REGISTRY_UPLOAD
20
21+ # This is a known slow task that will exceed the timeouts for
22+ # the normal job queue, so put it on a queue with longer timeouts
23+ task_queue = 'launchpad_job_slow'
24+
25+ soft_time_limit = timedelta(minutes=60)
26+ lease_duration = timedelta(minutes=60)
27+
28 class ManifestListUploadError(Exception):
29 pass
30
31diff --git a/lib/lp/oci/tests/test_ocirecipebuildjob.py b/lib/lp/oci/tests/test_ocirecipebuildjob.py
32index 95718bb..9dfb785 100644
33--- a/lib/lp/oci/tests/test_ocirecipebuildjob.py
34+++ b/lib/lp/oci/tests/test_ocirecipebuildjob.py
35@@ -53,10 +53,7 @@ from lp.services.database.locking import (
36 from lp.services.features.testing import FeatureFixture
37 from lp.services.job.interfaces.job import JobStatus
38 from lp.services.job.runner import JobRunner
39-from lp.services.job.tests import (
40- block_on_job,
41- pop_remote_notifications,
42- )
43+from lp.services.job.tests import block_on_job
44 from lp.services.statsd.tests import StatsMixin
45 from lp.services.webapp import canonical_url
46 from lp.services.webhooks.testing import LogsScheduledWebhooks
47@@ -71,7 +68,7 @@ from lp.testing.dbuser import (
48 from lp.testing.fakemethod import FakeMethod
49 from lp.testing.fixture import ZopeUtilityFixture
50 from lp.testing.layers import (
51- CeleryJobLayer,
52+ CelerySlowJobLayer,
53 DatabaseFunctionalLayer,
54 LaunchpadZopelessLayer,
55 )
56@@ -519,7 +516,6 @@ class TestOCIRegistryUploadJob(TestCaseWithFactory, MultiArchRecipeMixin,
57
58 self.assertContentEqual([], ocibuild.registry_upload_jobs)
59 job = OCIRegistryUploadJob.create(ocibuild)
60- client = FakeRegistryClient()
61 switch_dbuser(config.IOCIRegistryUploadJobSource.dbuser)
62 # Fork so that we can take an advisory lock from a different
63 # PostgreSQL session.
64@@ -551,8 +547,6 @@ class TestOCIRegistryUploadJob(TestCaseWithFactory, MultiArchRecipeMixin,
65 os.kill(pid, signal.SIGINT)
66
67
68-
69-
70 class TestOCIRegistryUploadJobViaCelery(TestCaseWithFactory,
71 MultiArchRecipeMixin):
72 """Runs OCIRegistryUploadJob via Celery, to make sure the machinery
73@@ -563,7 +557,7 @@ class TestOCIRegistryUploadJobViaCelery(TestCaseWithFactory,
74 so we should make sure we are not breaking anything in the interaction
75 with the job lifecycle via celery.
76 """
77- layer = CeleryJobLayer
78+ layer = CelerySlowJobLayer
79
80 def setUp(self):
81 super(TestOCIRegistryUploadJobViaCelery, self).setUp()
82@@ -583,4 +577,5 @@ class TestOCIRegistryUploadJobViaCelery(TestCaseWithFactory,
83 for build in builds:
84 OCIRegistryUploadJob.create(build)
85 transaction.commit()
86- self.assertEqual(0, len(pop_remote_notifications()))
87+ messages = [message.as_string() for message in pop_notifications()]
88+ self.assertEqual(0, len(messages))
89diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
90index 1060fa9..541ef56 100644
91--- a/lib/lp/testing/layers.py
92+++ b/lib/lp/testing/layers.py
93@@ -1899,6 +1899,24 @@ class CeleryJobLayer(AppServerLayer):
94 cls.celery_worker = None
95
96
97+class CelerySlowJobLayer(AppServerLayer):
98+ """Layer for tests that run jobs via Celery."""
99+
100+ celery_worker = None
101+
102+ @classmethod
103+ @profiled
104+ def setUp(cls):
105+ cls.celery_worker = celery_worker('launchpad_job_slow')
106+ cls.celery_worker.__enter__()
107+
108+ @classmethod
109+ @profiled
110+ def tearDown(cls):
111+ cls.celery_worker.__exit__(None, None, None)
112+ cls.celery_worker = None
113+
114+
115 class CeleryBzrsyncdJobLayer(AppServerLayer):
116 """Layer for tests that run jobs that read from branches via Celery."""
117

Subscribers

People subscribed via source and target branches

to status/vote changes: