Merge lp:~cjwatson/lazr.jobrunner/userErrorTypes into lp:lazr.jobrunner

Proposed by Colin Watson on 2012-10-24
Status: Merged
Approved by: Aaron Bentley on 2012-10-25
Approved revision: 46
Merged at revision: 46
Proposed branch: lp:~cjwatson/lazr.jobrunner/userErrorTypes
Merge into: lp:lazr.jobrunner
Diff against target: 52 lines (+26/-1)
2 files modified
src/lazr/jobrunner/jobrunner.py (+4/-1)
src/lazr/jobrunner/tests/test_jobrunner.py (+22/-0)
To merge this branch: bzr merge lp:~cjwatson/lazr.jobrunner/userErrorTypes
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2012-10-24 Approve on 2012-10-25
Review via email: mp+131248@code.launchpad.net

Commit Message

Support user_error_types even when security-proxied.

Description of the Change

JobRunner has an arrangement to cooperate with Launchpad to remove security proxies from job.retry_error_types, but it has no such arrangement for user_error_types. As a result, user_error_types does not in fact work, as far as I can tell, leading to OOPSes that should be caught.

This change mirrors the code for retry_error_types. It is a no-op on its own, and will require a subsequent change to Launchpad to take useful effect.

To post a comment you must log in.
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/jobrunner/jobrunner.py'
2--- src/lazr/jobrunner/jobrunner.py 2012-04-19 20:45:05 +0000
3+++ src/lazr/jobrunner/jobrunner.py 2012-10-24 18:04:21 +0000
4@@ -192,7 +192,7 @@
5 try:
6 try:
7 self.runJob(job, fallback)
8- except job.user_error_types, e:
9+ except self.userErrorTypes(job), e:
10 self.logger.info(
11 '%s failed with user error %r.'
12 % (self.job_str(job), e))
13@@ -211,6 +211,9 @@
14 def retryErrorTypes(self, job):
15 return job.retry_error_types
16
17+ def userErrorTypes(self, job):
18+ return job.user_error_types
19+
20 @staticmethod
21 @contextmanager
22 def oopsMessage(message):
23
24=== modified file 'src/lazr/jobrunner/tests/test_jobrunner.py'
25--- src/lazr/jobrunner/tests/test_jobrunner.py 2012-04-19 19:58:33 +0000
26+++ src/lazr/jobrunner/tests/test_jobrunner.py 2012-10-24 18:04:21 +0000
27@@ -332,3 +332,25 @@
28 runner.runJobHandleError(job)
29 self.assertEqual(JobStatus.WAITING, job.status)
30 self.assertEqual(1, job.attempt_count)
31+
32+ def test_runner_obeys_user_error_types_method(self):
33+
34+ class UserError(Exception):
35+ pass
36+
37+ class UserErrorRunner(JobRunner):
38+
39+ def userErrorTypes(self, job):
40+ return (UserError,)
41+
42+ runner = UserErrorRunner(
43+ logger=self.logger, oops_config=self.oops_config)
44+ job = FakeJob(1, UserError('no OOPS expected'))
45+ self.assertFalse(job.notifyUserError_called)
46+ runner.runJobHandleError(job)
47+ self.assertEqual(0, self.oops_repository.oops_count)
48+ self.assertEqual(
49+ "<FakeJob> (ID 1) failed with user error "
50+ "UserError('no OOPS expected',).",
51+ self.log_handler.records[-1].msg)
52+ self.assertTrue(job.notifyUserError_called)

Subscribers

People subscribed via source and target branches

to all changes: