Merge ~cjwatson/launchpad:job-retry-no-oops into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 3c1cbd915f7fbb3a4ba17df9561aa456b6557ac4
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:job-retry-no-oops
Merge into: launchpad:master
Diff against target: 67 lines (+18/-4)
2 files modified
constraints.txt (+1/-1)
lib/lp/services/job/tests/test_runner.py (+17/-3)
Reviewer Review Type Date Requested Status
Tom Wardill (community) Approve
Review via email: mp+373804@code.launchpad.net

Commit message

Upgrade to lazr.jobrunner 0.16, and test for lack of OOPSes on retry

Description of the change

lazr.jobrunner 0.16 also adds Python 3 support, although we'll need to upgrade to Celery 4.3 or newer before being able to take advantage of that.

The retry OOPS fix comes from https://code.launchpad.net/~cjwatson/lazr.jobrunner/quieter-retry-handling/+merge/369697 (merged).

This is essentially the same as https://code.launchpad.net/~cjwatson/launchpad/job-retry-no-oops/+merge/372556, converted to git and rebased on master.

To post a comment you must log in.
Revision history for this message
Tom Wardill (twom) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/constraints.txt b/constraints.txt
2index fa23f05..df3cea6 100644
3--- a/constraints.txt
4+++ b/constraints.txt
5@@ -286,7 +286,7 @@ lazr.batchnavigator==1.2.11
6 lazr.config==2.2.1
7 lazr.delegates==2.0.4
8 lazr.enum==1.1.3
9-lazr.jobrunner==0.14
10+lazr.jobrunner==0.16
11 lazr.lifecycle==1.1
12 lazr.restful==0.20.1
13 lazr.restfulclient==0.13.2
14diff --git a/lib/lp/services/job/tests/test_runner.py b/lib/lp/services/job/tests/test_runner.py
15index d1001ff..62a2376 100644
16--- a/lib/lp/services/job/tests/test_runner.py
17+++ b/lib/lp/services/job/tests/test_runner.py
18@@ -44,6 +44,7 @@ from lp.services.job.runner import (
19 TwistedJobRunner,
20 )
21 from lp.services.log.logger import BufferLogger
22+from lp.services.scripts.logger import OopsHandler
23 from lp.services.timeline.requesttimeline import get_request_timeline
24 from lp.services.timeout import (
25 get_default_timeout_function,
26@@ -366,18 +367,29 @@ class TestJobRunner(TestCaseWithFactory):
27
28 def test_runJobHandleErrors_user_error_no_oops(self):
29 """If the job raises a user error, there is no oops."""
30+ logging.getLogger().addHandler(OopsHandler('test_runner'))
31 job = RaisingJobUserError('boom')
32 runner = JobRunner([job])
33 runner.runJobHandleError(job)
34 self.assertEqual(0, len(self.oopses))
35
36+ def test_runJobHandleErrors_retry_error_no_oops(self):
37+ """If the job raises a retry error, there is no oops."""
38+ logging.getLogger().addHandler(OopsHandler('test_runner'))
39+ job = RaisingRetryJob('completion')
40+ runner = JobRunner([job])
41+ runner.runJobHandleError(job)
42+ self.assertEqual(0, len(self.oopses))
43+
44 def test_runJob_raising_retry_error(self):
45 """If a job raises a retry_error, it should be re-queued."""
46 job = RaisingRetryJob('completion')
47- runner = JobRunner([job])
48+ logger = BufferLogger()
49+ logger.setLevel(logging.INFO)
50+ runner = JobRunner([job], logger=logger)
51 self.assertIs(None, job.scheduled_start)
52- with self.expectedLog('Scheduling retry due to RetryError'):
53- runner.runJob(job, None)
54+ self.addCleanup(lambda: self.addDetail('log', logger.content))
55+ runner.runJob(job, None)
56 self.assertEqual(JobStatus.WAITING, job.status)
57 expected_delay = datetime.now(UTC) + timedelta(minutes=10)
58 self.assertThat(
59@@ -388,6 +400,8 @@ class TestJobRunner(TestCaseWithFactory):
60 self.assertIsNone(job.lease_expires)
61 self.assertNotIn(job, runner.completed_jobs)
62 self.assertIn(job, runner.incomplete_jobs)
63+ self.assertIn(
64+ 'Scheduling retry due to RetryError', logger.getLogBuffer())
65
66 def test_runJob_exceeding_max_retries(self):
67 """If a job exceeds maximum retries, it should raise normally."""

Subscribers

People subscribed via source and target branches

to status/vote changes: