Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: always accept to resize a partition that is being wiped #2149

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions subiquity/common/filesystem/manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,13 @@ def reformat(self, disk, ptable=None, wipe=None):
self.delete_partition(p, True)
self.clear(disk, wipe)

def can_resize_partition(self, partition):
def can_resize_partition(self, partition, *, wipe=None):
# For a new partition.
if not partition.preserve:
return True
# For an existing partition that is being wiped.
if wipe is not None:
return True
if partition.format not in get_resize_fstypes():
return False
return True
Expand All @@ -297,7 +301,7 @@ def partition_disk_handler(
size_change = new_size - partition.size
if size_change > gap_size:
raise Exception("partition size too large")
if not self.can_resize_partition(partition):
if not self.can_resize_partition(partition, wipe=spec.get("wipe")):
raise Exception("partition cannot support resize")
partition.size = new_size
partition.resize = True
Expand Down
6 changes: 6 additions & 0 deletions subiquity/common/filesystem/tests/test_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,3 +754,9 @@ def test_resize_invalid(self):
part = make_partition(self.manipulator.model, disk, preserve=True)
make_filesystem(self.manipulator.model, partition=part, fstype="asdf")
self.assertFalse(self.manipulator.can_resize_partition(part))

def test_resize_invalid_but_wipe(self):
disk = make_disk(self.manipulator.model, ptable=None)
part = make_partition(self.manipulator.model, disk, preserve=True)
make_filesystem(self.manipulator.model, partition=part, fstype="asdf")
self.assertTrue(self.manipulator.can_resize_partition(part, wipe="superblock"))
Loading