From 938f2ffc2432d2c7dbd69cb5503aa256ec63fbda Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 12 Apr 2023 11:25:05 +0200 Subject: [PATCH] mirror: avoid assertion error if the source changes at the wrong time When the source model changes, the mirror model gets notified and replaces the "apt configurer" instance with a new one. If this happens in the middle of a "deploy apt configuration + run apt-get update" operation, this leads to an assertion error. Fixed by making sure we do the entire operation on the same "apt configurer" instance. Signed-off-by: Olivier Gayot --- subiquity/server/controllers/mirror.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subiquity/server/controllers/mirror.py b/subiquity/server/controllers/mirror.py index cc283701..cd3be2b6 100644 --- a/subiquity/server/controllers/mirror.py +++ b/subiquity/server/controllers/mirror.py @@ -314,9 +314,14 @@ class MirrorController(SubiquityController): async def run_mirror_testing(self, output: io.StringIO) -> None: await self.source_configured_event.wait() - await self.test_apt_configurer.apply_apt_config( + # If the source model changes at the wrong time, there is a chance that + # self.test_apt_configurer will be replaced between the call to + # apply_apt_config and run_apt_config_check. Just make sure we still + # use the original one. + configurer = self.test_apt_configurer + await configurer.apply_apt_config( self.context, final=False) - await self.test_apt_configurer.run_apt_config_check(output) + await configurer.run_apt_config_check(output) async def wait_config(self) -> AptConfigurer: self.final_apt_configurer = get_apt_configurer(