Skip to content
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
25 changes: 15 additions & 10 deletions kiwi/builder/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,19 @@ def _build_and_map_disk_partitions(
(self.root_clone_count + 1) * squashed_rootfs_mbsize if \
self.root_clone_count else squashed_rootfs_mbsize

root_clone_count = self.root_clone_count
if self.root_filesystem_is_overlay:
# in overlay mode an eventual root clone is created from
# the root readonly partition and not from the root (rw)
# partition. Thus no further action needed here in this
# case
root_clone_count = 0

if self.spare_part_mbsize and self.spare_part_is_last:
rootfs_mbsize = disksize_mbytes - disksize_used_mbytes - \
self.spare_part_mbsize - Defaults.get_min_partition_mbytes()
if root_clone_count:
rootfs_mbsize = int(rootfs_mbsize / (root_clone_count + 1))
else:
if self.oem_systemsize and not self.oem_resize:
rootfs_mbsize = self.oem_systemsize
Expand All @@ -1209,18 +1219,13 @@ def _build_and_map_disk_partitions(
'--> overlayroot explicitly requested no write partition'
)
else:
root_clone_count = self.root_clone_count
if self.root_filesystem_is_overlay:
# in overlay mode an eventual root clone is created from
# the root readonly partition and not from the root (rw)
# partition. Thus no further action needed here in this
# case
root_clone_count = 0
if root_clone_count:
if rootfs_mbsize == 'all_free':
clone_rootfs_mbsize = disksize_mbytes - \
disksize_used_mbytes - Defaults.get_min_partition_mbytes()
clone_rootfs_mbsize = int(
(disksize_mbytes - disksize_used_mbytes) / (root_clone_count + 1)
) + Defaults.get_min_partition_mbytes()
clone_rootfs_mbsize / (root_clone_count + 1)
)
rootfs_mbsize = \
f'clone:{clone_rootfs_mbsize}:{clone_rootfs_mbsize}'
else:
Expand All @@ -1247,7 +1252,7 @@ def _build_and_map_disk_partitions(
)
disk.create_root_partition(rootfs_mbsize, root_clone_count)

if self.spare_part_mbsize and self.spare_part_is_last:
if self.spare_part_is_last:
log.info('--> creating spare partition')
disk.create_spare_partition(
'all_free'
Expand Down
15 changes: 14 additions & 1 deletion test/unit/builder/disk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def test_create_disk_standard_root_with_clone(
format(self.disk_setup.boot_partition_size()), 1
)
disk.create_root_partition.assert_called_once_with(
'clone:458:458', 1
'clone:443:443', 1
)
disk.create_custom_partitions.assert_called_once_with(
self.disk_builder.custom_partitions
Expand All @@ -581,10 +581,23 @@ def test_create_disk_standard_root_with_clone(
call([self.device_map['rootclone1']])
]

# Test in spare part mode
self.disk_builder.spare_part_mbsize = 42
self.disk_builder.spare_part_is_last = True
disk.create_root_partition.reset_mock()
with patch('builtins.open', m_open, create=True):
self.disk_builder.create_disk()

disk.create_root_partition.assert_called_once_with(
'clone:422:422', 1
)

# Test in overlay mode a root clone is created from
# the root readonly partition and not from the root (rw)
# partition.
self.disk_builder.root_filesystem_is_overlay = True
self.disk_builder.spare_part_mbsize = None
self.disk_builder.spare_part_is_last = False
disk.create_root_partition.reset_mock()
with patch('builtins.open', m_open, create=True):
self.disk_builder.create_disk()
Expand Down