Merge lp:~paulgear/python-oops-tools/variable-retention-period into lp:python-oops-tools

Proposed by Paul Gear
Status: Needs review
Proposed branch: lp:~paulgear/python-oops-tools/variable-retention-period
Merge into: lp:python-oops-tools
Diff against target: 40 lines (+9/-6)
1 file modified
src/oopstools/scripts/prune.py (+9/-6)
To merge this branch: bzr merge lp:~paulgear/python-oops-tools/variable-retention-period
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
William Grant Pending
Review via email: mp+289862@code.launchpad.net

Description of the change

Landscape have requested longer retention for OOPSes; this is a (presently-untested) change to allow that. cRT#89955

To post a comment you must log in.
58. By Paul Gear

Specify option type

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Unmerged revisions

58. By Paul Gear

Specify option type

57. By Paul Gear

Update documentation for --retention

56. By Paul Gear

Allow use of different retention periods

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/oopstools/scripts/prune.py'
2--- src/oopstools/scripts/prune.py 2012-12-05 17:30:35 +0000
3+++ src/oopstools/scripts/prune.py 2016-03-23 06:47:39 +0000
4@@ -53,9 +53,9 @@
5 Project and projectgroup can be supplied multiple times.
6
7 When run this program will ask Launchpad for OOPS references made since
8- the last date it pruned up to, with an upper limit of one week from
9- today. It then looks in the database for all oopses created during that
10- date range, and if they are not in the set returned by Launchpad,
11+ the last date it pruned up to, using the upper limit specified with
12+ --retention. It then looks in the database for all oopses created during
13+ that date range, and if they are not in the set returned by Launchpad,
14 deletes them. If the database has never been pruned before, it will
15 pick the earliest date present in the repository as the start date.
16
17@@ -73,6 +73,9 @@
18 help="Launchpad project group to find references in.")
19 parser.add_option(
20 '--lpinstance', help="Launchpad instance to use", default="production")
21+ parser.add_option(
22+ '--retention', help="Number of days to keep OOPSes", default=7,
23+ type="int")
24 options, args = parser.parse_args(argv[1:])
25 def needed(*optnames):
26 present = set()
27@@ -88,10 +91,10 @@
28 needed('project', 'projectgroup')
29 logging.basicConfig(
30 filename='logs/prune.log', filemode='w', level=logging.DEBUG)
31- one_week = datetime.timedelta(weeks=1)
32+ retention = datetime.timedelta(days=options.retention)
33 one_day = datetime.timedelta(days=1)
34- # Only prune OOPS reports more than one week old.
35- prune_until = datetime.datetime.now(utc) - one_week
36+ # Only prune OOPS reports older than the retention period
37+ prune_until = datetime.datetime.now(utc) - retention
38 # Ignore OOPS reports we already found references for - older than the last
39 # prune date.
40 try:

Subscribers

People subscribed via source and target branches

to all changes: