Don't search github api for projects not in Zuul

We see cases where the github driver uses the search API to learn more
about an PR but ends up return information about other projects not in
Zuuls configuration. In some cases, this results in zuul getting
rate-limited by github, which can block event processing.

Change-Id: Ie09eee17e1adf87c212da240eeaa8c098d48a1d6
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
Co-Authored-By: Clark Boylan <clark.boylan@gmail.com>
This commit is contained in:
Paul Belanger 2019-11-14 14:22:21 -05:00 committed by Clark Boylan
parent 22af945568
commit 27a718e32f
1 changed files with 11 additions and 0 deletions

View File

@ -1173,6 +1173,17 @@ class GithubConnection(BaseConnection):
proj = pr.get('base').get('repo').get('full_name')
sha = pr.get('head').get('sha')
key = (proj, num, sha)
# A single tenant could have multiple projects with the same
# name on different sources. Ensure we use the canonical name
# to handle that case.
s_project = self.source.getProject(proj)
trusted, t_project = tenant.getProject(
s_project.canonical_name)
# ignore projects zuul doesn't know about
if not t_project:
continue
if key in keys:
continue
self.log.debug("Found PR %s/%s needs %s/%s" %