From bc6e859109bda8ab25c8e1ebf6dabcb73357a59a Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 May 2020 23:02:16 +1200 Subject: [PATCH 1/2] round autoinstall partition sizes using percentages down to a megabyte boundary https://bugs.launchpad.net/subiquity/+bug/1876874 --- subiquity/models/filesystem.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 7877fd6a..b3b70b7d 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -1375,7 +1375,8 @@ class FilesystemModel(object): elif isinstance(p.size, str): if p.size.endswith("%"): percentage = int(p.size[:-1]) - p.size = parent.available_for_partitions*percentage//100 + p.size = align_down( + parent.available_for_partitions*percentage//100) else: p.size = dehumanize_size(p.size) From ba106bbbed21fafab5f93de98a3df6bbe857433e Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Tue, 5 May 2020 23:05:59 +1200 Subject: [PATCH 2/2] tests --- examples/autoinstall.yaml | 4 ++-- scripts/validate-yaml.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/autoinstall.yaml b/examples/autoinstall.yaml index c87c3756..1e0a196e 100644 --- a/examples/autoinstall.yaml +++ b/examples/autoinstall.yaml @@ -37,8 +37,8 @@ storage: - {type: partition, device: disk-2, size: 1M, wipe: superblock, flag: bios_grub, number: 1, preserve: false, id: partition-grub-2} - {type: partition, device: disk-1, size: 1G, wipe: superblock, number: 2, preserve: false, id: partition-boot-1} - {type: partition, device: disk-2, size: 1G, wipe: superblock, number: 2, preserve: false, id: partition-boot-2} - - {type: partition, device: disk-1, size: 3G, wipe: superblock, number: 3, preserve: false, id: partition-system-1} - - {type: partition, device: disk-2, size: 3G, wipe: superblock, number: 3, preserve: false, id: partition-system-2} + - {type: partition, device: disk-1, size: 17%, wipe: superblock, number: 3, preserve: false, id: partition-system-1} + - {type: partition, device: disk-2, size: 17%, wipe: superblock, number: 3, preserve: false, id: partition-system-2} - {type: raid, name: md0, raidlevel: raid1, devices: [partition-boot-1, partition-boot-2], preserve: false, id: raid-boot} - {type: raid, name: md1, raidlevel: raid1, devices: [partition-system-1, partition-system-2], preserve: false, id: raid-system} - {type: format, fstype: ext4, volume: raid-boot, preserve: false, id: format-boot} diff --git a/scripts/validate-yaml.py b/scripts/validate-yaml.py index 56b32764..9b53566b 100644 --- a/scripts/validate-yaml.py +++ b/scripts/validate-yaml.py @@ -14,6 +14,7 @@ class StorageChecker: def _check_partition(self, action): assert 'device' in action assert 'size' in action + assert action['size'] % 512 == 0 assert 'number' in action assert action['device'] in self.actions assert 'ptable' in self.actions[action['device']] @@ -49,6 +50,7 @@ class StorageChecker: assert 'name' in action assert 'size' in action assert isinstance(action['size'], str) + assert int(action['size'][:-1]) % 512 == 0 assert action['volgroup'] in self.actions def check(self, action):