Skip to content

Commit

Permalink
Bug 1735145 - only drop relevant stockwell tags from a bugs whiteboard (
Browse files Browse the repository at this point in the history
#7311)

Until now, the intermittent failures commenter would often drop all stockwell
tags from the whiteboard when the bug got updated. Information got lost, e.g.
the test having already been disabled (at least partially on 1+ platforms).
  • Loading branch information
Archaeopteryx authored Nov 9, 2021
1 parent bf5cc7e commit 346bdb9
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions treeherder/intermittents_commenter/commenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ def generate_bug_changes(self, startday, endday, alt_startday, alt_endday):
bug_info[bug_id]['whiteboard']
):
priority = 3
change_whiteboard = self.update_whiteboard(
bug_info[bug_id]['whiteboard'], '[stockwell disable-recommended]'
change_whiteboard = bug_info[bug_id]['whiteboard'].replace(
'[stockwell unknown]', ''
)
change_whiteboard = re.sub(
r'\s*\[stockwell needswork[^\]]*\]\s*', '', change_whiteboard
).strip()
change_whiteboard += '[stockwell disable-recommended]'

comment = template.render(
bug_id=bug_id,
Expand Down Expand Up @@ -128,23 +132,21 @@ def check_needswork_owner(self, bug_info):
if bug_info['priority'] not in ['--', 'P1', 'P2', 'P3']:
change_priority = '--'

stockwell_text = re.search(r'\[stockwell (.+?)\]', bug_info['whiteboard'])
stockwell_labels = re.findall(r'\[stockwell (.+?)\]', bug_info['whiteboard'])
# update whiteboard text unless it already contains WHITEBOARD_NEEDSWORK_OWNER
if stockwell_text is None or stockwell_text.group() != WHITEBOARD_NEEDSWORK_OWNER:
change_whiteboard = self.update_whiteboard(
bug_info['whiteboard'], WHITEBOARD_NEEDSWORK_OWNER
)
if WHITEBOARD_NEEDSWORK_OWNER not in stockwell_labels:
change_whiteboard = bug_info['whiteboard'] + WHITEBOARD_NEEDSWORK_OWNER

return change_priority, change_whiteboard

def check_needswork(self, whiteboard):
stockwell_text = re.search(r'\[stockwell (.+?)\]', whiteboard)
stockwell_labels = re.findall(r'\[stockwell needswork[^\]]*\]', whiteboard)
if len(stockwell_labels) == 0:
return None
# update all [stockwell needswork] bugs (including all 'needswork' possibilities,
# ie 'needswork:owner') and update whiteboard to [stockwell unknown]
if stockwell_text is not None and stockwell_text.group(1).split(':')[0] == 'needswork':
return self.update_whiteboard(whiteboard, '[stockwell unknown]')

return None
change_whiteboard = re.sub(r'\s*\[stockwell needswork[^\]]*\]\s*', '', whiteboard).strip()
return change_whiteboard + '[stockwell unknown]'

def assign_priority(self, counts):
priority = 0
Expand Down Expand Up @@ -206,10 +208,6 @@ def check_whiteboard_status(self, whiteboard):
return True
return False

def update_whiteboard(self, existing, new):
whiteboard = re.sub(r'\[stockwell.*?\]', '', existing)
return whiteboard + new

def new_request(self):
session = requests.Session()
# Use a custom HTTP adapter, so we can set a non-zero max_retries value.
Expand Down

0 comments on commit 346bdb9

Please sign in to comment.