-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overlaygen: cap max sparse file size
If the source system has a very large disk attached, leapp would attempt to create similarly large sparse file, possibly hitting the max file size limits of the filesystem where these images are created. This patch caps the maximum size of any of the created sparse files to 1TB, preventing such issues. Jira ref: RHEL-57064
- Loading branch information
Michal Hecko
committed
Sep 5, 2024
1 parent
41e32e3
commit 7495b2d
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
repos/system_upgrade/common/libraries/tests/test_overlaygen.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from collections import namedtuple | ||
|
||
from leapp.libraries.common import overlaygen | ||
|
||
|
||
class RunMocked(object): | ||
def __init__(self): | ||
self.invocations = [] | ||
|
||
def __call__(self, *args, **kwargs): | ||
self.invocations.append((args, kwargs)) | ||
|
||
|
||
def test_prepare_required_mounts_image_size_capping(monkeypatch): | ||
""" Test whether having a very large disk will not create very large image. """ | ||
MountPoint = namedtuple('MountPoint', 'fs_file') | ||
mount_points = [MountPoint(fs_file='/big_disk')] | ||
monkeypatch.setattr(overlaygen, '_get_mountpoints', lambda storage_info: mount_points) | ||
monkeypatch.setattr(overlaygen, '_get_scratch_mountpoint', lambda *args: '/scratch') | ||
monkeypatch.setattr(overlaygen, '_create_diskimages_dir', lambda *args: None) | ||
monkeypatch.setattr(overlaygen, '_ensure_enough_diskimage_space', lambda *args: None) | ||
|
||
mountpoint_sizes = { | ||
'/big_disk': 20*(1024**2), # 20TB | ||
'/scratch': 20 # Arbitrary, irrelevant for this test | ||
} | ||
monkeypatch.setattr(overlaygen, '_get_fspace', lambda mount, *args, **kwargs: mountpoint_sizes[mount]) | ||
monkeypatch.setattr(overlaygen, 'run', RunMocked()) | ||
|
||
def create_disk_image_mock(disk_images_dir, mountpoint, disk_size): | ||
assert mountpoint == '/big_disk' | ||
assert disk_size == overlaygen._MAX_DISK_IMAGE_SIZE_MB | ||
|
||
monkeypatch.setattr(overlaygen, '_create_mount_disk_image', create_disk_image_mock) | ||
|
||
storage_info = None # Should not be used in the code due to how we mocked overlaygen functions | ||
overlaygen._prepare_required_mounts('/scratch', '/mounts', storage_info, 100) |