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 <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2023-02-01 21:54:37 +01:00
parent 5711660d5d
commit 38bb82f43f
1 changed files with 11 additions and 1 deletions

View File

@ -167,6 +167,9 @@ class MirrorController(SubiquityController):
# Sleep before testing the next candidate.. # Sleep before testing the next candidate..
log.debug("Will check next candiate mirror after 10 seconds.") log.debug("Will check next candiate mirror after 10 seconds.")
await asyncio.sleep(10) await asyncio.sleep(10)
if candidate.uri is None:
log.debug("Skipping unresolved country mirror")
continue
candidate.stage() candidate.stage()
try: try:
await self.try_mirror_checking_once() await self.try_mirror_checking_once()
@ -250,7 +253,14 @@ class MirrorController(SubiquityController):
# TODO farfetched # TODO farfetched
if self.model.primary_elected is not None: if self.model.primary_elected is not None:
return self.model.primary_elected.uri 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: async def POST(self, url: Optional[str]) -> None:
if url is not None: if url is not None: