Skip to content

Commit f918c36

Browse files
authored
Skipping CCd users without GAIA accounts for buganizer issues (#4406)
### Motivation oss_fuzz_build_status and oss_fuzz_apply_ccs are broken due to buganizer rejecting emails without associated accounts. This serves as a workaround so at least some notifications can suceeed. (google/oss-fuzz#12536) ### Why this works Buganizer throws 400 errors listing out all rejected emails in the exception, so we can just parse the non gaia emails from that and complete the execution by ignoring those. ### Testing strategy Ran both cronjobs locally with the proposed new code, and verified they ran to completion.
1 parent 737b835 commit f918c36

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

src/clusterfuzz/_internal/cron/oss_fuzz_apply_ccs.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def cc_users_for_job(job_type, security_flag):
3939

4040

4141
def main():
42-
"""Cron handler for adding new CC's to oss-fuzz bugs.."""
42+
"""Cron handler for adding new CC's to oss-fuzz bugs."""
43+
some_issue_failed = False
4344
for testcase in get_open_testcases_with_bugs():
4445
issue_tracker = issue_tracker_utils.get_issue_tracker_for_testcase(testcase)
4546
if not issue_tracker:
@@ -67,7 +68,16 @@ def main():
6768
logging.info('CCing %s on %s', cc, issue.id)
6869
issue.ccs.add(cc)
6970

70-
issue.save(notify=True)
71+
try:
72+
issue.save(notify=True)
73+
except Exception as e:
74+
some_issue_failed = True
75+
logging.error('Failed to apply ccs for test case '
76+
'%s: %s.', testcase.key, e)
77+
78+
if some_issue_failed:
79+
logging.error('OSS fuzz apply ccs failed.')
80+
return False
7181

7282
logging.info('OSS fuzz apply ccs succeeded.')
7383
return True

src/clusterfuzz/_internal/issue_management/google_issue_tracker/issue_tracker.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import datetime
1919
import enum
20+
import functools
21+
import re
2022
from typing import List
2123
from typing import Optional
2224
from typing import Sequence
@@ -68,6 +70,24 @@ def _get_access_limit_from_labels(labels: issue_tracker.LabelStore):
6870
return None
6971

7072

73+
def retry_on_invalid_gaia_accounts(func):
74+
"""Decorator to retry saving an issue, skipping CCs
75+
without a GAIA account."""
76+
77+
@functools.wraps(func)
78+
def wrapper(self, *args, **kwargs):
79+
try:
80+
return func(self, *args, **kwargs)
81+
except Exception as e:
82+
# Try to handle the case where a 400 buganizer response is
83+
# received due to a non gaia email.
84+
email_regex = r'[\w\.\-\+]+@[\w\.-]+'
85+
emails_to_skip = re.findall(email_regex, str(e))
86+
return func(self, *args, **kwargs, skip_emails=emails_to_skip)
87+
88+
return wrapper
89+
90+
7191
class IssueTrackerError(Exception):
7292
"""Base issue tracker error."""
7393

@@ -719,8 +739,10 @@ def _update_issue(self, new_comment=None, notify=True):
719739
issueId=str(self.id)))
720740
return result
721741

722-
def save(self, new_comment=None, notify=True):
742+
@retry_on_invalid_gaia_accounts
743+
def save(self, new_comment=None, notify=True, skip_emails=[]): # pylint: disable=dangerous-default-value
723744
"""Saves the issue."""
745+
logs.info(f'Skipping supposed non gaia emails emails: {skip_emails}.')
724746
if self._is_new:
725747
logs.info('google_issue_tracker: Creating new issue..')
726748
priority = _extract_label(self.labels, 'Pri-') or _DEFAULT_PRIORITY
@@ -793,7 +815,9 @@ def save(self, new_comment=None, notify=True):
793815

794816
if self.component_id:
795817
self._data['issueState']['componentId'] = int(self.component_id)
796-
ccs = list(self._ccs)
818+
# TODO(vitorguidi): delete this hack once we have a solution for GAIA.
819+
# Skip CCd users w/o a GAIA account
820+
ccs = list(set(self._ccs) - set(skip_emails))
797821
if ccs:
798822
self._data['issueState']['ccs'] = _make_users(ccs)
799823
collaborators = list(self._collaborators)
@@ -822,6 +846,10 @@ def save(self, new_comment=None, notify=True):
822846
self._is_new = False
823847
else:
824848
logs.info('google_issue_tracker: Updating issue..')
849+
# TODO(vitorguidi): remove this once we have a fix for GAIA.
850+
# Remove all CCd users w/o GAIA accounts
851+
for email in skip_emails:
852+
self.ccs.remove(email)
825853
result = self._update_issue(new_comment=new_comment, notify=notify)
826854
self._reset_tracking()
827855
self._data = result
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"target": "linux/arm64", "reproduce": false, "workdir": "/home/vitorguidi/projects/clusterfuzz/src/clusterfuzz/_internal/tests/core/bot/fuzzers/syzkaller/input/syzkaller", "http": "localhost:0", "syzkaller": "/home/vitorguidi/projects/clusterfuzz/src/clusterfuzz/_internal/tests/core/bot/fuzzers/syzkaller/build/syzkaller", "suppressions": ["do_rt_sigqueueinfo", "do_rt_tgsigqueueinfo"], "vm": {"devices": ["172.18.0.2:6520"]}, "kernel_obj": "/home/vitorguidi/projects/clusterfuzz/src/clusterfuzz/_internal/tests/core/bot/fuzzers/syzkaller/build", "sandbox": "android", "ignores": ["WARNING:", "INFO:"], "type": "adb", "procs": 1, "cover": true}

0 commit comments

Comments
 (0)