diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-07-14 22:47:00 +0100 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-07-15 17:16:59 +0100 |
commit | 755dc86c41392c7065440d147258befbbeb5c1ee (patch) | |
tree | 9b1901ebc25459a0f1801d185a6f03756d73e6d0 /lorrycontroller | |
parent | c93409d4493f1374d626f21f9f68def3a88f09a6 (diff) | |
download | lorry-controller-755dc86c41392c7065440d147258befbbeb5c1ee.tar.gz |
givemejob: Stop synthesising host information when it's missing
Any lorry in the database should have been either:
1. Generated based on a 'trove' or 'gitlab' section, with
'from_host' set to the Upstream Host name.
2. Read from a lorry referred to in a 'lorries' section, with
'from_host' set to an empty string.
So this error case indicates a dangling reference in the database.
The current schema does not use foreign keys so this could happen,
but it's reasonable to just give up and return empty metadata.
Diffstat (limited to 'lorrycontroller')
-rw-r--r-- | lorrycontroller/givemejob.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/lorrycontroller/givemejob.py b/lorrycontroller/givemejob.py index 1a0fe35..8f4a2a8 100644 --- a/lorrycontroller/givemejob.py +++ b/lorrycontroller/givemejob.py @@ -76,16 +76,9 @@ class GiveMeJob(lorrycontroller.LorryControllerRoute): try: host_info = statedb.get_host_info(lorry_info['from_host']) except lorrycontroller.HostNotFoundError: - # XXX We don't know whether upstream is Trove. It should be - # possible to set host type for single repositories. - host_info = { - 'host': lorry_info['from_host'], - 'protocol': 'ssh', - 'username': None, - 'password': None, - 'type': 'trove', - 'type_params': {}, - } + # XXX Shouldn't happen, but currently the database schema + # does not prevent it + return {} metadata = lorrycontroller.get_upstream_host(host_info) \ .get_repo_metadata(lorry_info['from_path']) |