Skip to content

Commit

Permalink
filesystem: do not keep the variation info when the source changes
Browse files Browse the repository at this point in the history
When the source changes, the available variations should change as well.
If we keep the old variations in the
FilesystemController._variations_info dictionary, we end up with a crash
later in the install.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
  • Loading branch information
ogayot committed Oct 10, 2023
1 parent 65612ed commit d482049
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def disallowed_encryption(msg):
return info

async def _examine_systems(self):
self._variation_info.clear()
catalog_entry = self.app.base_model.source.current
for name, variation in catalog_entry.variations.items():
system = None
Expand Down
30 changes: 30 additions & 0 deletions subiquity/server/controllers/tests/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,36 @@ async def fake_run(cmd, **kwargs):
await self.fsc._pre_shutdown()
mock_run.assert_called_once_with(["mountpoint", "/target"])

async def test_examine_systems(self):
# In LP: #2037723 and other similar reports, the user selects the
# source 'ubuntu-desktop-minimal' first and then switches to
# 'ubuntu-desktop'. The variations of those two sources are different.
# Upon switching to the new source, we forgot to discard the old
# variations. This lead to a crash further in the install.
self.fsc.model = model = make_model(Bootloader.UEFI)
make_disk(model)
self.app.base_model.source.current.type = "fsimage"
self.app.base_model.source.current.variations = {
"minimal": CatalogEntryVariation(path="", size=1),
}

self.app.dr_cfg = DRConfig()
self.app.dr_cfg.systems_dir_exists = True

await self.fsc._examine_systems()

self.assertEqual(len(self.fsc._variation_info), 1)
self.assertEqual(self.fsc._variation_info["minimal"].name, "minimal")

self.app.base_model.source.current.variations = {
"default": CatalogEntryVariation(path="", size=1),
}

await self.fsc._examine_systems()

self.assertEqual(len(self.fsc._variation_info), 1)
self.assertEqual(self.fsc._variation_info["default"].name, "default")


class TestGuided(IsolatedAsyncioTestCase):
boot_expectations = [
Expand Down

0 comments on commit d482049

Please sign in to comment.