From 38bb82f43f1fe99e7391a85fbeece78ecacee3d2 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 1 Feb 2023 21:54:37 +0100 Subject: [PATCH] mirror: skip unresolved mirrors on GET /mirror and autoinstalls Country mirrors start with no URI. Make sure we skip those if we don't receive a geoip query response. Signed-off-by: Olivier Gayot --- subiquity/server/controllers/mirror.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/subiquity/server/controllers/mirror.py b/subiquity/server/controllers/mirror.py index 71c97e3f..a20fdac3 100644 --- a/subiquity/server/controllers/mirror.py +++ b/subiquity/server/controllers/mirror.py @@ -167,6 +167,9 @@ class MirrorController(SubiquityController): # Sleep before testing the next candidate.. log.debug("Will check next candiate mirror after 10 seconds.") await asyncio.sleep(10) + if candidate.uri is None: + log.debug("Skipping unresolved country mirror") + continue candidate.stage() try: await self.try_mirror_checking_once() @@ -250,7 +253,14 @@ class MirrorController(SubiquityController): # TODO farfetched if self.model.primary_elected is not None: return self.model.primary_elected.uri - return self.model.primary_candidates[0].uri + for candidate in self.model.compatible_primary_candidates(): + if candidate.uri is None: + # Country mirror that has not yet been resolved. + continue + return candidate.uri + # We should always have at least one candidate, albeit + # archive.ubuntu.com, with a URI. + assert False async def POST(self, url: Optional[str]) -> None: if url is not None: