diff --git a/subiquity/server/controllers/filesystem.py b/subiquity/server/controllers/filesystem.py index 2d70bc13..5af288a3 100644 --- a/subiquity/server/controllers/filesystem.py +++ b/subiquity/server/controllers/filesystem.py @@ -162,7 +162,11 @@ class VariationInfo: ) -> CapabilityInfo: r = CapabilityInfo() r.disallowed = list(self.capability_info.disallowed) - if self.capability_info.allowed and gap.size < install_min: + if gap is None: + gap_size = 0 + else: + gap_size = gap.size + if self.capability_info.allowed and gap_size < install_min: for capability in self.capability_info.allowed: r.disallowed.append( GuidedDisallowedCapability( diff --git a/subiquity/server/controllers/tests/test_filesystem.py b/subiquity/server/controllers/tests/test_filesystem.py index c9734bdd..f891d789 100644 --- a/subiquity/server/controllers/tests/test_filesystem.py +++ b/subiquity/server/controllers/tests/test_filesystem.py @@ -695,7 +695,7 @@ class TestGuidedV2(IsolatedAsyncioTestCase): self.assertEqual([reformat, manual], guided_get_resp.targets) @parameterized.expand(bootloaders_and_ptables) - async def test_small_blank_disk(self, bootloader, ptable): + async def test_small_blank_disk_1GiB(self, bootloader, ptable): await self._setup(bootloader, ptable, size=1 << 30) resp = await self.fsc.v2_guided_GET() expected = [ @@ -708,6 +708,28 @@ class TestGuidedV2(IsolatedAsyncioTestCase): ] self.assertEqual(expected, resp.targets) + @parameterized.expand(bootloaders_and_ptables) + async def test_small_blank_disk_1MiB(self, bootloader, ptable): + await self._setup(bootloader, ptable, size=1 << 20) + resp = await self.fsc.v2_guided_GET() + + reformat = GuidedStorageTargetReformat( + disk_id=self.disk.id, + allowed=[], + disallowed=default_capabilities_disallowed_too_small, + ) + manual = GuidedStorageTargetManual() + + # depending on bootloader/ptable combo, GuidedStorageTargetReformat may + # show up but it will all be disallowed. + for target in resp.targets: + if isinstance(target, GuidedStorageTargetManual): + self.assertEqual(target, manual) + elif isinstance(target, GuidedStorageTargetReformat): + self.assertEqual(target, reformat) + else: + raise Exception(f"unexpected target {target}") + @parameterized.expand(bootloaders_and_ptables) async def test_used_half_disk(self, bootloader, ptable): await self._setup(bootloader, ptable, size=100 << 30)