check-release-approval: log Gerrit data on error

We've had hard-to-track exceptions with missing keys in Gerrit
query answers. Let's log the JSON in case of KeyError parsing
Gerrit response.

Change-Id: I495c225022250f9fa055c12c422071b1f42ff753
This commit is contained in:
Thierry Carrez 2020-02-12 18:05:00 +01:00
parent e17d562000
commit 1ad4a5f899
1 changed files with 16 additions and 9 deletions

View File

@ -85,15 +85,22 @@ class GerritChange(object):
# Instantiate object with retrieved data
self.raw_data = decoded
self.approvers = [i['email']
for i in decoded['labels']['Code-Review']['all']
if i['value'] > 0]
self.approvers.append(decoded['owner']['email'])
currev = decoded['current_revision']
self.deliv_files = [
x for x in decoded['revisions'][currev]['files'].keys()
if x.startswith('deliverables/')
]
try:
self.approvers = [i['email']
for i in decoded['labels']['Code-Review']['all']
if i['value'] > 0]
self.approvers.append(decoded['owner']['email'])
currev = decoded['current_revision']
self.deliv_files = [
x for x in decoded['revisions'][currev]['files'].keys()
if x.startswith('deliverables/')
]
except KeyError:
LOG.error(
'\ndata from gerrit is missing required keys:\n\n' +
json.dumps(decoded, indent=2) + '\n')
raise
self.workspace = args.releases
def is_approved(self):