Merge lp:~adeuring/launchpad/put-retry-jobs-into-celery-queue into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Aaron Bentley | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 15263 | ||||
Proposed branch: | lp:~adeuring/launchpad/put-retry-jobs-into-celery-queue | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
227 lines (+153/-4) 3 files modified
lib/lp/services/job/model/job.py (+8/-2) lib/lp/services/job/runner.py (+18/-2) lib/lp/services/job/tests/test_retry_jobs_with_celery.py (+127/-0) |
||||
To merge this branch: | bzr merge lp:~adeuring/launchpad/put-retry-jobs-into-celery-queue | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aaron Bentley (community) | Approve | ||
Review via email: mp+106012@code.launchpad.net |
Commit message
generate a Celery task when a job raises a retry error
Description of the change
One of the last missing details to run jobs via Celery: When a job
raises a retry execption, a new Celery request for the next attempt
to run the job must be issued.
A new request is created by BaseRunnableJob
called in a hook when the DB transaction is committed. When a retry
execption occurs, the job runner calls job.queue(), which was up to
now only implemented in lp.services.
class is/was not aware of any Celery related details, so I added
a method BaseRunnableJob
Calling celeryRunOnCommit() directly in BaseRunnableJob
other problems: The hook must be added before a transaction committed --
but lp.services.
twice, and job status is set to WAITING in the second commit call.
TO get the Celery hook placed into the "right" commit, I added the
optional parameter add_commit_hook to
lp.services.
BaseRunnableJob
exists. If so, it uses the lease expiration time as the ETA for the
new Celery request. The implementation looks a bit convoluted: Launchpad
uses datetime instances _with_ a timezone, but Celery works only with
datetime instances _without_ a timezone...
I changed UniversalJobSource so that we can create test jobs which do
not have a related DB table like "regular jobs".
test: ./bin/test -vvt lp.services.
no lint