launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04373
[Merge] lp:~julian-edwards/launchpad/lease-time-bug-816326 into lp:launchpad
Julian Edwards has proposed merging lp:~julian-edwards/launchpad/lease-time-bug-816326 into lp:launchpad.
Requested reviews:
Aaron Bentley (abentley)
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #816326 in Launchpad itself: "Jobs that unsuspend themselves take a long time to restart"
https://bugs.launchpad.net/launchpad/+bug/816326
For more details, see:
https://code.launchpad.net/~julian-edwards/launchpad/lease-time-bug-816326/+merge/69266
= Summary =
Make job resumption clear the lease_expires so that it can be picked up by a runner right away.
== Implementation details ==
A very trivial change! But submitted for review to double check that it will
DTRT in all circumstances.
== Tests ==
bin/test -cvv test_job
== Demo and Q/A ==
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/services/job/tests/test_job.py
lib/lp/services/job/model/job.py
--
https://code.launchpad.net/~julian-edwards/launchpad/lease-time-bug-816326/+merge/69266
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~julian-edwards/launchpad/lease-time-bug-816326 into lp:launchpad.
=== modified file 'lib/lp/services/job/model/job.py'
--- lib/lp/services/job/model/job.py 2011-07-15 10:40:44 +0000
+++ lib/lp/services/job/model/job.py 2011-07-26 12:23:35 +0000
@@ -182,6 +182,7 @@
if self.status is not JobStatus.SUSPENDED:
raise InvalidTransition(self._status, JobStatus.WAITING)
self._set_status(JobStatus.WAITING)
+ self.lease_expires = None
Job.ready_jobs = Select(
=== modified file 'lib/lp/services/job/tests/test_job.py'
--- lib/lp/services/job/tests/test_job.py 2011-07-15 10:40:44 +0000
+++ lib/lp/services/job/tests/test_job.py 2011-07-26 12:23:35 +0000
@@ -223,6 +223,13 @@
job.status,
JobStatus.WAITING)
+ def test_resume_clears_lease_expiry(self):
+ """A job that resumes should null out the lease_expiry."""
+ job = Job(_status=JobStatus.SUSPENDED)
+ job.lease_expires = UTC_NOW
+ job.resume()
+ self.assertIs(None, job.lease_expires)
+
def test_resume_when_running(self):
"""When a job is running, attempting to resume is invalid."""
job = Job(_status=JobStatus.RUNNING)
Follow ups