diff options
author | Ian Wienand <iwienand@redhat.com> | 2021-09-23 16:57:48 +1000 |
---|---|---|
committer | Ian Wienand <iwienand@redhat.com> | 2021-09-23 19:53:52 +1000 |
commit | 6518b9822326af6f121d2be0a2ea8429a1e42d84 (patch) | |
tree | 228d010a9e03ae6424fa4eb5a86dcf34704d1f1a /zuul/driver/github | |
parent | 403d1c2882e27206d32946238cff2d7e7f3b661c (diff) | |
download | zuul-6518b9822326af6f121d2be0a2ea8429a1e42d84.tar.gz |
github: handle suspended apps
Admins can "suspend" an app [1]; emperically testing this apps see
"suspended_at" and "suspended_by" populated and any further calls
return a 400 response.
Skip adding projects if the app has been suspended.
[1] https://docs.github.com/en/developers/apps/managing-github-apps/suspending-a-github-app-installation
Change-Id: I3f508a0bf7d992b5bd2713f01c8e5a1b2a17b917
Diffstat (limited to 'zuul/driver/github')
-rw-r--r-- | zuul/driver/github/githubconnection.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/zuul/driver/github/githubconnection.py b/zuul/driver/github/githubconnection.py index 690494950..cb50b7897 100644 --- a/zuul/driver/github/githubconnection.py +++ b/zuul/driver/github/githubconnection.py @@ -1061,7 +1061,18 @@ class GithubClientManager: page += 1 response = requests.get(url, headers=headers) response.raise_for_status() - installations.extend(response.json()) + for i in response.json(): + # admins can hit "suspend app" which populates + # this in the app response. A suspended app + # will just get back 400 "This installation + # has been suspended" responses. + if i.get('suspended_at'): + self.log.info("Skipping GitHub installation %s due" + " to admin suspension (by %s @ %s)" % + (i['id'], i['suspended_by']['login'], + i['suspended_at'])) + else: + installations.append(i) # check if we need to do further paged calls url = response.links.get( |