Skip to content

Commit

Permalink
If we can't parse SCM URL from Koji, send an error result (#218)
Browse files Browse the repository at this point in the history
If Greenwave can't parse the SCM URL for a Koji build (which can
happen if the build is run from a .src.rpm, which Koji admins
can do), it raises an exception in `_get_sub_policies`, which
ultimately results in the query returning 502. This doesn't give
a great experience in Bodhi - it'll just show no automated test
results and the gating status will be stuck at 'waiting' forever.
Using browser developer tools you can determine that it's getting
a 502 from Greenwave, but you can't tell why (we had to find that
out from greenwave's logs, in the real-world case here).

If we have Greenwave instead handle the exception and send a
response that includes an unsatisfied requirement indicating the
error, that should result in a better experience in Bodhi. The
gating status will be failed, test results will be shown, and the
UI will give at least some indication that there was an error
trying to retrieve remote policies. With developer tools you
should see the exact error in the Greenwave response JSON.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
  • Loading branch information
AdamWill committed Dec 6, 2023
1 parent b23ef50 commit aa7489f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions greenwave/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ def _get_sub_policies(self, policy, subject):
logging.exception('Unexpected Koji XMLRPC fault with code: %s', err.faultCode)
error = f'Koji XMLRPC fault due to: \'{err.faultString}\''
raise BadGateway(error)
except BadGateway as err:
error = err.description
if 'Failed to parse SCM URL' in error:
return [], [FailedFetchRemoteRuleYaml(subject, remote_policies_urls, error)]
raise err
except Exception:
logging.exception('Failed to retrieve policies for %r', subject)
error = 'Unexpected error while fetching remote policies'
Expand Down

0 comments on commit aa7489f

Please sign in to comment.