From b9f9aee39989284266a0174cfa764cbeca21d383 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 14 Sep 2022 16:55:49 +0200 Subject: [PATCH] mirror: only start configuring APT once source & mirror are configured The mirror controller is responsible from creating the APT configuration once its associated model is marked configured. However, the APT configuration is also dependent on the source model being marked configured. When subiquity is used for the server installer, the client immediately sends a POST /a/meta/client_variant request. This ends up marking the source model as configured (even though the default value does not make much sense). So we never end up in a scenario where the mirror model is marked configured before the source model. When Subiquity is used by a different client, such as the ubuntu-desktop-installer, it is possible that we mark the mirror model configured first. This ends up crashing the installer. Fixed by adding a dependency on the source model so that we do not end up creating the APT configuration too early. Signed-off-by: Olivier Gayot --- subiquity/server/controllers/mirror.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/subiquity/server/controllers/mirror.py b/subiquity/server/controllers/mirror.py index fdec14cc..834e5fdf 100644 --- a/subiquity/server/controllers/mirror.py +++ b/subiquity/server/controllers/mirror.py @@ -84,7 +84,8 @@ class MirrorController(SubiquityController): self.app.hub.subscribe( (InstallerChannels.CONFIGURED, 'source'), self.on_source) self.cc_event = asyncio.Event() - self.configured_once = False + self.configured_event = asyncio.Event() + self.source_configured_event = asyncio.Event() self._apt_config_key = None self._apply_apt_config_task = SingleInstanceTask( self._apply_apt_config) @@ -113,8 +114,8 @@ class MirrorController(SubiquityController): self.cc_event.set() def on_source(self): - if self.configured_once: - self._apply_apt_config_task.start_sync() + self._apply_apt_config_task.start_sync() + self.source_configured_event.set() def serialize(self): return self.model.get_mirror() @@ -129,10 +130,13 @@ class MirrorController(SubiquityController): async def configured(self): await super().configured() - self.configured_once = True self._apply_apt_config_task.start_sync() + self.configured_event.set() async def _apply_apt_config(self): + await asyncio.gather(self.configured_event.wait(), + self.source_configured_event.wait()) + # if self.apt_configurer is not None: # FIXME disabled until we can sort out umount # await self.apt_configurer.cleanup()