From 755dc86c41392c7065440d147258befbbeb5c1ee Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 14 Jul 2020 22:47:00 +0100 Subject: 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. --- lorrycontroller/givemejob.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'lorrycontroller') 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']) -- cgit v1.2.1