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 <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-09-14 16:55:49 +02:00
parent 80869d23f2
commit b9f9aee399
1 changed files with 8 additions and 4 deletions

View File

@ -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.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()