update the script to expire old bug reports
With commit 623587c76d
a script to expire
old bug reports got introduced. This change updates a few things:
* print an ascii table after the bug reports has been closed
(in case you want to paste it on the ML)
* fix the script argument "--no_dry_run" to fit the conventions
* Change the bug task status from "won't fix" to "expired" (this
feedback came from the ops ML [1])
* improve the wording of the bug comment a little
* avoid the INFO logging of used libs
[1] http://lists.openstack.org/pipermail/openstack-operators/2016-May/010577.html
Change-Id: I6055ba4bfc8d08998a0e8451fe515a2b4796ce72
This commit is contained in:
parent
15ec2e7e4c
commit
c3dcb46b81
|
@ -7,7 +7,7 @@
|
|||
# * have the importance "Wishlist"
|
||||
#
|
||||
# example execution:
|
||||
# $ python expire_old_bug_reports.py nova --no_dry_run
|
||||
# $ python expire_old_bug_reports.py nova --no-dry-run
|
||||
#
|
||||
#
|
||||
# Copyright 2016 Markus Zoeller (mzoeller@linux.vnet.ibm.com)
|
||||
|
@ -31,16 +31,17 @@ import argparse
|
|||
import datetime
|
||||
import logging
|
||||
import os
|
||||
from prettytable import PrettyTable
|
||||
import sys
|
||||
import time
|
||||
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
import lazr.restfulclient.errors
|
||||
|
||||
|
||||
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(funcName)s - %(message)s"
|
||||
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
|
||||
logging.basicConfig(format=LOG_FORMAT)
|
||||
LOG = logging.getLogger(__name__)
|
||||
LOG.setLevel(logging.INFO)
|
||||
|
||||
parser = argparse.ArgumentParser(description="Expire old bug reports.")
|
||||
parser.add_argument('project_name',
|
||||
|
@ -48,7 +49,8 @@ parser.add_argument('project_name',
|
|||
parser.add_argument('--verbose', '-v',
|
||||
help='Enable debug logging.',
|
||||
action="store_true")
|
||||
parser.add_argument('--no_dry_run',
|
||||
parser.add_argument('--no-dry-run',
|
||||
dest='no_dry_run',
|
||||
help='Execute the expiration for real.',
|
||||
action='store_true')
|
||||
parser.add_argument('--credentials-file', '-c',
|
||||
|
@ -69,6 +71,10 @@ DAYS_SINCE_CREATED = 30 * 18 # 18 months
|
|||
STILL_VALID_FLAG = "CONFIRMED FOR: %(release_name)s" # UPPER CASE
|
||||
SUPPORTED_RELEASE_NAMES = [] # UPPER CASE
|
||||
|
||||
BUG_TASK_STATUS_AFTER_RUN = "Expired"
|
||||
BUG_TASK_ASSIGNEE_AFTER_RUN = None
|
||||
BUG_TASK_IMPORTANCE_AFTER_RUN = "Undecided"
|
||||
|
||||
|
||||
class BugReport(object):
|
||||
|
||||
|
@ -154,14 +160,14 @@ def get_expired_reports(lp_project):
|
|||
def expire_bug_report(bug_report):
|
||||
subject = "Cleanup EOL bug report"
|
||||
comment = """
|
||||
This is an automated cleanup. This bug report got closed because it
|
||||
This is an automated cleanup. This bug report has been closed because it
|
||||
is older than %(mm)d months and there is no open code change to fix this.
|
||||
After this time it is unlikely that the circumstances which lead to
|
||||
the observed issue can be reproduced.
|
||||
|
||||
If you can reproduce it, please:
|
||||
If you can reproduce the bug, please:
|
||||
* reopen the bug report (set to status "New")
|
||||
* AND add the steps to reproduce the issue (if applicable)
|
||||
* AND add the detailed steps to reproduce the issue (if applicable)
|
||||
* AND leave a comment "CONFIRMED FOR: <RELEASE_NAME>"
|
||||
Only still supported release names are valid (%(supported_releases)s).
|
||||
Valid example: CONFIRMED FOR: %(valid_release_name)s
|
||||
|
@ -170,20 +176,31 @@ If you can reproduce it, please:
|
|||
'valid_release_name': SUPPORTED_RELEASE_NAMES[0]}
|
||||
|
||||
bug_task = bug_report.bug_task
|
||||
bug_task.status = "Won't Fix"
|
||||
bug_task.assignee = None
|
||||
bug_task.importance = "Undecided"
|
||||
bug_task.status = BUG_TASK_STATUS_AFTER_RUN
|
||||
bug_task.assignee = BUG_TASK_ASSIGNEE_AFTER_RUN
|
||||
bug_task.importance = BUG_TASK_IMPORTANCE_AFTER_RUN
|
||||
try:
|
||||
if args.no_dry_run:
|
||||
bug_task.lp_save()
|
||||
bug_task.bug.newMessage(subject=subject, content=comment)
|
||||
LOG.debug("expired bug report %s" % bug_report)
|
||||
LOG.debug("expired bug report %s" % bug_report)
|
||||
except lazr.restfulclient.errors.ServerError as e:
|
||||
LOG.error(" - TIMEOUT during save ! (%s)" % e, end='')
|
||||
except Exception as e:
|
||||
LOG.error(" - ERROR during save ! (%s)" % e, end='')
|
||||
|
||||
|
||||
def print_expired_table(expired_reports):
|
||||
x = PrettyTable()
|
||||
x.field_names = ["Bug #", "Title", "Age (d)"]
|
||||
x.align["Bug #"] = "r"
|
||||
x.align["Title"] = "l"
|
||||
x.align["Age (d)"] = "r"
|
||||
for r in expired_reports:
|
||||
x.add_row([r.bug_task.bug.id, r.title, r.age])
|
||||
print(x)
|
||||
|
||||
|
||||
def main():
|
||||
if args.no_dry_run:
|
||||
LOG.info("This is not a drill! Bug reports will be closed for real!")
|
||||
|
@ -196,7 +213,10 @@ def main():
|
|||
LOG.info("starting expiration...")
|
||||
for e in expired_reports:
|
||||
expire_bug_report(e)
|
||||
LOG.info("expiration done")
|
||||
LOG.info("expired %d bug reports.", len(expired_reports))
|
||||
LOG.info("printing an ASCII table for notification purposes...")
|
||||
print_expired_table(expired_reports)
|
||||
LOG.info("printed ASCII table.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -4,6 +4,7 @@ requests>=1.1
|
|||
Jinja2>=2.6 # BSD License (3 clause)
|
||||
oslo.concurrency>=1.4.1 # Apache-2.0
|
||||
parawrap
|
||||
prettytable
|
||||
# 2013.6 is the first version of pytz that is PEP 440 compatible.
|
||||
pytz>=2013.6
|
||||
PyYAML>=3.1.0
|
||||
|
|
Loading…
Reference in New Issue