Merge pull request #1957 from ogayot/target-resize-part-mounted

filesystem: don't suggest target resize if part is mounted
This commit is contained in:
Olivier Gayot 2024-04-02 09:53:31 +02:00 committed by GitHub
commit 224d9cde1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -1141,6 +1141,8 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
for disk in self.potential_boot_disks(check_boot=False):
part_align = disk.alignment_data().part_align
for partition in disk.partitions():
if partition._is_in_use:
continue
vals = sizes.calculate_guided_resize(
partition.estimated_min_size,
partition.size,

View File

@ -902,6 +902,25 @@ class TestGuidedV2(IsolatedAsyncioTestCase):
self.assertTrue(isinstance(resize, GuidedStorageTargetResize))
self.assertEqual(1, len(resp.targets))
@parameterized.expand(bootloaders_and_ptables)
async def test_used_half_disk_mounted(self, bootloader, ptable):
# When a partition is already mounted, it can't be resized.
await self._setup(bootloader, ptable, size=100 << 30)
p = make_partition(
self.model, self.disk, preserve=True, size=50 << 30, is_in_use=True
)
self.fs_probe[p._path()] = {"ESTIMATED_MIN_SIZE": 1 << 20}
resp = await self.fsc.v2_guided_GET()
reformat = resp.targets.pop(0)
self.assertEqual(
GuidedStorageTargetReformat(
disk_id=self.disk.id, allowed=default_capabilities
),
reformat,
)
self.assertEqual(1, len(resp.targets))
@parameterized.expand(bootloaders_and_ptables)
async def test_used_full_disk(self, bootloader, ptable):
await self._setup(bootloader, ptable)