Skip to content

Commit

Permalink
storage: exclude erase-install scenarios that renumber partitions
Browse files Browse the repository at this point in the history
The /storage/v2 API currently does not deal well with partitions
renumbering. For logical partitions, renumbering automatically occurs
when a partition is removed or added. This leads to inconsistencies and
mismatches in the info returned by the /storage/v2 API ; as reported in
https://launchpad.net/bugs/2091172

The result of the these inconsistencies gets reflected in the summary of
storage changes shown to the user in the UI. Having wrong information
there will scare people away.

For now, we will avoid producing guided erase and install scenarios if
it means renumbering partitions.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
  • Loading branch information
ogayot committed Jan 16, 2025
1 parent d4fa209 commit 74a781c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,17 @@ def available_erase_install_scenarios(
if partition.os is None:
continue

if (
partition.is_logical
and disk.partitions_by_number()[-1] != partition
):
# FIXME If we remove this partition, the subsequent logical
# partitions will be renumbered. This will cause various
# mismatches in the info returned by /storage/v2. For now,
# we exclude this scenario.
# See LP: #2091172
continue

# Make an ephemeral copy of the disk object with the relevant
# partition removed. Then it's as if we're installing in the
# resulting gap (which will include free space that was
Expand Down
8 changes: 5 additions & 3 deletions subiquity/server/controllers/tests/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1822,10 +1822,12 @@ async def test_available_erase_install_scenarios__with_logical_partitions(self):
sorted_scenarios = sorted(
scenarios, key=lambda sc: (sc.disk_id, sc.partition_number)
)
# Currently we expect only two scenarios because of the workaround for
# LP: #2091172. If we drop the workaround, we will have a third
# scenario for partition p5.
self.assertEqual(1, sorted_scenarios[0].partition_number)
self.assertEqual(5, sorted_scenarios[1].partition_number)
self.assertEqual(6, sorted_scenarios[2].partition_number)
self.assertEqual(3, len(sorted_scenarios))
self.assertEqual(6, sorted_scenarios[1].partition_number)
self.assertEqual(2, len(sorted_scenarios))

async def test_resize_has_enough_room_for_partitions__one_primary(self):
await self._setup(Bootloader.NONE, "gpt", fix_bios=True)
Expand Down

0 comments on commit 74a781c

Please sign in to comment.