launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01654
[Merge] lp:~deryck/launchpad/expiry-script-updates into lp:launchpad/devel
Deryck Hodge has proposed merging lp:~deryck/launchpad/expiry-script-updates into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
This branch adds the ability to run cronscripts/expire-bugtasks.py for only a
few Ubuntu bugtasks at a time. The idea is that we'll do batch runs of expire
bugtasks, i.e. only expiring 200 Ubuntu bugtasks at a time, until we see if
everything is working as expected.
To do this, I extended the cronscript itself to accept -u (for ubuntu) and -l
(for limit) params. So it can be run like:
./cronscripts/expire-bugtasks.py -u -l 200
Or, if you like:
./cronscripts/expire-bugtasks.py --ubuntu --limit 200
This would expire only 200 of Ubuntu's expirable bugtasks.
The code also updates lp.bugs.scripts.bugexpire.BugJanitor to accept these
params. BugTask.findExpirableBugTasks already accepted a target argument, so
nothing needed to be done or tests added for limiting to Ubuntu. However,
findExpirableBugTasks needed to be updated to accept and make use of a limit
param. The doc test was updated for the limit param since it was new.
Test with:
./bin/test -cvvt bugtask-expiration
Thanks for the review!
--
https://code.launchpad.net/~deryck/launchpad/expiry-script-updates/+merge/39090
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~deryck/launchpad/expiry-script-updates into lp:launchpad/devel.
=== modified file 'cronscripts/expire-bugtasks.py'
--- cronscripts/expire-bugtasks.py 2010-04-27 19:48:39 +0000
+++ cronscripts/expire-bugtasks.py 2010-10-21 20:22:43 +0000
@@ -15,6 +15,8 @@
import _pythonpath
+from zope.component import getUtility
+
from canonical.config import config
from lp.services.scripts.base import LaunchpadCronScript
from lp.bugs.scripts.bugexpire import BugJanitor
@@ -30,9 +32,23 @@
usage = "usage: %prog [options]"
description = ' %s' % __doc__
+ def add_my_options(self):
+ self.parser.add_option('-u', '--ubuntu', action='store_true',
+ dest='ubuntu', default=False,
+ help='Only expire Ubuntu bug tasks.')
+ self.parser.add_option('-l', '--limit', action='store', dest='limit',
+ type='int', metavar='NUMBER', default=None,
+ help='Limit expiry to NUMBER of bug tasks.')
+
def main(self):
"""Run the BugJanitor."""
- janitor = BugJanitor(log=self.logger)
+ target = None
+ if self.options.ubuntu:
+ # Avoid circular import.
+ from lp.registry.interfaces.distribution import IDistributionSet
+ target = getUtility(IDistributionSet).getByName('ubuntu')
+ janitor = BugJanitor(
+ log=self.logger, target=target, limit=self.options.limit)
janitor.expireBugTasks(self.txn)
=== modified file 'lib/lp/bugs/doc/bugtask-expiration.txt'
--- lib/lp/bugs/doc/bugtask-expiration.txt 2010-10-19 18:44:31 +0000
+++ lib/lp/bugs/doc/bugtask-expiration.txt 2010-10-21 20:22:43 +0000
@@ -350,6 +350,16 @@
hoary True 351 Incomplete False False False False
recent False 31 Incomplete False False False False
+findExpirableBugTasks also accepts a limit argument, which allows for limiting
+the number of bugtasks returned.
+
+ >>> expirable_bugtasks = bugtaskset.findExpirableBugTasks(
+ ... 0, None, target=ubuntu, limit=2)
+ >>> summarize_bugtasks(expirable_bugtasks)
+ ROLE EXPIRE AGE STATUS ASSIGNED DUP MILE REPLIES
+ ubuntu True 351 Incomplete False False False False
+ hoary True 351 Incomplete False False False False
+
Thunderbird has not enabled bug expiration. Even when the min_days_old
is set to 0, no bugtasks are replaced.
=== modified file 'lib/lp/bugs/interfaces/bugtask.py'
--- lib/lp/bugs/interfaces/bugtask.py 2010-09-21 09:37:06 +0000
+++ lib/lp/bugs/interfaces/bugtask.py 2010-10-21 20:22:43 +0000
@@ -1440,7 +1440,8 @@
Exactly one of product, distribution or distroseries must be provided.
"""
- def findExpirableBugTasks(min_days_old, user, bug=None, target=None):
+ def findExpirableBugTasks(min_days_old, user, bug=None, target=None,
+ limit=None):
"""Return a list of bugtasks that are at least min_days_old.
:param min_days_old: An int representing the minimum days of
@@ -1453,6 +1454,7 @@
:param target: An `IBugTarget`. If a target is provided, only
bugtasks that belong to the target may be returned. If target
is None, all bugtargets are searched.
+ :param limit: An int for limiting the number of bugtasks returned.
:return: A ResultSet of bugtasks that are considered expirable.
A bugtask is expirable if its status is Incomplete, and the bug
=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2010-09-23 10:27:11 +0000
+++ lib/lp/bugs/model/bugtask.py 2010-10-21 20:22:43 +0000
@@ -2417,7 +2417,7 @@
return cur.fetchall()
def findExpirableBugTasks(self, min_days_old, user,
- bug=None, target=None):
+ bug=None, target=None, limit=None):
"""See `IBugTaskSet`.
The list of Incomplete bugtasks is selected from products and
@@ -2483,6 +2483,8 @@
unconfirmed_bug_condition,
clauseTables=['Bug'],
orderBy='Bug.date_last_updated')
+ if limit is not None:
+ expirable_bugtasks = expirable_bugtasks.limit(limit)
return expirable_bugtasks
=== modified file 'lib/lp/bugs/scripts/bugexpire.py'
--- lib/lp/bugs/scripts/bugexpire.py 2010-08-20 20:31:18 +0000
+++ lib/lp/bugs/scripts/bugexpire.py 2010-10-21 20:22:43 +0000
@@ -36,13 +36,16 @@
must use Malone for bug tracking.
"""
- def __init__(self, days_before_expiration=None, log=None):
+ def __init__(self, days_before_expiration=None, log=None, target=None,
+ limit=None):
"""Create a new BugJanitor.
:days_before_expiration: Days of inactivity before a question is
expired. Defaults to config.malone.days_before_expiration.
:log: A logger instance to use for logging. Defaults to the default
logger.
+ :target: The target for expiring bugs.
+ :limit: Expire no more than limit bugtasks.
"""
if days_before_expiration is None:
@@ -52,6 +55,8 @@
log = getLogger()
self.days_before_expiration = days_before_expiration
self.log = log
+ self.target = target
+ self.limit = limit
self.janitor = getUtility(ILaunchpadCelebrities).janitor
@@ -73,7 +78,8 @@
expired_count = 0
bugtask_set = getUtility(IBugTaskSet)
incomplete_bugtasks = bugtask_set.findExpirableBugTasks(
- self.days_before_expiration, user=self.janitor)
+ self.days_before_expiration, user=self.janitor,
+ target=self.target, limit=self.limit)
self.log.info(
'Found %d bugtasks to expire.' % incomplete_bugtasks.count())
for bugtask in incomplete_bugtasks:
Follow ups