Skip to content

Commit

Permalink
Bug 1453760 - Bug commenter: Skip bugs when metadata not retrievable (#…
Browse files Browse the repository at this point in the history
…3856)

Since certain bug metadata is not retrievable (even with an API key)
and returns a 401 Authorization Required (eg security bugs). 

The whiteboard is also now only updated if it has changed.
  • Loading branch information
sarah-clements authored and edmorley committed Aug 1, 2018
1 parent e330c68 commit 6b8cdf6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/intermittents_commenter/test_commenter.py
Expand Up @@ -12,7 +12,6 @@ def test_intermittents_commenter(bug_data):
alt_endday = endday

process = Commenter(weekly_mode=True, dry_run=True)
comment_params = process.generate_bug_changes(startday, endday, alt_startday, alt_endday)
url = process.create_url(bug_data['bug_id']) + '?include_fields={}'.format(TRIAGE_PARAMS['include_fields'])

content = {
Expand All @@ -34,6 +33,11 @@ def test_intermittents_commenter(bug_data):
match_querystring=True,
status=200))

resp = process.fetch_bug_details(TRIAGE_PARAMS, bug_data['bug_id'])
assert resp == content['bugs'][0]

comment_params = process.generate_bug_changes(startday, endday, alt_startday, alt_endday)

with open('tests/intermittents_commenter/expected_comment.text', 'r') as comment:
expected_comment = comment.read()

Expand Down
17 changes: 16 additions & 1 deletion treeherder/intermittents_commenter/commenter.py
Expand Up @@ -70,6 +70,9 @@ def generate_bug_changes(self, startday, endday, alt_startday, alt_endday):
# recommend disabling when more than 150 failures tracked over 21 days
if alt_bug_stats[bug_id]['total'] >= 150:
bug_info, whiteboard = self.check_bug_info(bug_info, bug_id)
# if fetch_bug_details fails (called in check_bug_info), None is returned
if bug_info is None:
continue

if not self.check_whiteboard_status(whiteboard):
priority = 3
Expand All @@ -79,17 +82,29 @@ def generate_bug_changes(self, startday, endday, alt_startday, alt_endday):
priority = self.assign_priority(priority, counts)
if priority == 2:
bug_info, whiteboard = self.check_bug_info(bug_info, bug_id)
# if fetch_bug_details fails (called in check_bug_info), None is returned
if bug_info is None:
continue

change_priority, whiteboard = self.check_needswork_owner(change_priority, bug_info, whiteboard)

# change [stockwell needswork] to [stockwell unknown] when failures drop below 20 failures/week
if (counts['total'] < 20):
bug_info, whiteboard = self.check_bug_info(bug_info, bug_id)
# if fetch_bug_details fails (called in check_bug_info), None is returned
if bug_info is None:
continue

whiteboard = self.check_needswork(whiteboard)

if bug_id in top_bugs:
rank = top_bugs.index(bug_id)+1
else:
bug_info, whiteboard = self.check_bug_info(bug_info, bug_id)
# if fetch_bug_details fails (called in check_bug_info), None is returned
if bug_info is None:
continue

change_priority, whiteboard = self.check_needswork_owner(change_priority, bug_info, whiteboard)

comment = template.render(bug_id=bug_id,
Expand All @@ -109,7 +124,7 @@ def generate_bug_changes(self, startday, endday, alt_startday, alt_endday):
'comment': {'body': comment}
}
}
if whiteboard:
if whiteboard != bug_info['whiteboard']:
bug_changes['changes']['whiteboard'] = whiteboard
if change_priority:
bug_changes['changes']['priority'] = change_priority
Expand Down

0 comments on commit 6b8cdf6

Please sign in to comment.