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
=== modified file 'src/oopstools/scripts/prune.py'
--- src/oopstools/scripts/prune.py 2012-12-05 17:30:35 +0000
+++ src/oopstools/scripts/prune.py 2016-03-23 06:47:39 +0000
@@ -53,9 +53,9 @@
53 Project and projectgroup can be supplied multiple times.53 Project and projectgroup can be supplied multiple times.
5454
55 When run this program will ask Launchpad for OOPS references made since55 When run this program will ask Launchpad for OOPS references made since
56 the last date it pruned up to, with an upper limit of one week from56 the last date it pruned up to, using the upper limit specified with
57 today. It then looks in the database for all oopses created during that57 --retention. It then looks in the database for all oopses created during
58 date range, and if they are not in the set returned by Launchpad,58 that date range, and if they are not in the set returned by Launchpad,
59 deletes them. If the database has never been pruned before, it will59 deletes them. If the database has never been pruned before, it will
60 pick the earliest date present in the repository as the start date.60 pick the earliest date present in the repository as the start date.
6161
@@ -73,6 +73,9 @@
73 help="Launchpad project group to find references in.")73 help="Launchpad project group to find references in.")
74 parser.add_option(74 parser.add_option(
75 '--lpinstance', help="Launchpad instance to use", default="production")75 '--lpinstance', help="Launchpad instance to use", default="production")
76 parser.add_option(
77 '--retention', help="Number of days to keep OOPSes", default=7,
78 type="int")
76 options, args = parser.parse_args(argv[1:])79 options, args = parser.parse_args(argv[1:])
77 def needed(*optnames):80 def needed(*optnames):
78 present = set()81 present = set()
@@ -88,10 +91,10 @@
88 needed('project', 'projectgroup')91 needed('project', 'projectgroup')
89 logging.basicConfig(92 logging.basicConfig(
90 filename='logs/prune.log', filemode='w', level=logging.DEBUG)93 filename='logs/prune.log', filemode='w', level=logging.DEBUG)
91 one_week = datetime.timedelta(weeks=1)94 retention = datetime.timedelta(days=options.retention)
92 one_day = datetime.timedelta(days=1)95 one_day = datetime.timedelta(days=1)
93 # Only prune OOPS reports more than one week old.96 # Only prune OOPS reports older than the retention period
94 prune_until = datetime.datetime.now(utc) - one_week97 prune_until = datetime.datetime.now(utc) - retention
95 # Ignore OOPS reports we already found references for - older than the last98 # Ignore OOPS reports we already found references for - older than the last
96 # prune date.99 # prune date.
97 try:100 try:

Subscribers

People subscribed via source and target branches

to all changes: