Skip to content

Commit

Permalink
Do not write LVM devices file during image installation
Browse files Browse the repository at this point in the history
Follow up for rhinstaller#5325 which disables the LVM devices file usage on
blivet side but we also need to skip writing the file when
writing the storage configuration post install.

Resolves: rhbz#2247872
  • Loading branch information
vojtechtrefny committed Feb 22, 2024
1 parent 38dcece commit 5e9db7c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pyanaconda/modules/storage/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ def _write_lvm_devices_file(storage, sysroot):
:param Blivet storage: instance of Blivet or a subclass
:param str sysroot: path to the target OS installation
"""
if conf.target.is_image:
log.debug("Don't write the LVM devices file during image installation.")
return

if not HAVE_LVMDEVICES:
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1529,8 +1529,9 @@ def test_write_configuration(self, patched_conf, dbus):
WriteConfigurationTask(storage).run()
assert os.path.exists("{}/etc".format(d))

@patch("pyanaconda.modules.storage.installation.conf")
@patch("pyanaconda.modules.storage.installation.os.path.exists", return_value=False)
def test_lvm_devices_file(self, exists_mock):
def test_lvm_devices_file(self, exists_mock, patched_conf):
"""Test writing the LVM devices file"""
dev1 = Mock()
dev1.format.type = "lvmpv"
Expand All @@ -1543,17 +1544,29 @@ def test_lvm_devices_file(self, exists_mock):
storage = Mock(devices=[dev1, dev2], devicetree=Mock(_hidden=[dev3, dev4]))

with tempfile.TemporaryDirectory() as tmp:
# lvm devices file: disabled
# lvm devices file: disabled, image installation: False
with patch("pyanaconda.modules.storage.installation.HAVE_LVMDEVICES", new=False):
patched_conf.target.is_image = False
WriteConfigurationTask._write_lvm_devices_file(storage, tmp)
dev1.format.lvmdevices_add.assert_not_called()
dev2.format.lvmdevices_add.assert_not_called()
dev3.format.lvmdevices_add.assert_not_called()
dev4.format.lvmdevices_add.assert_not_called()
exists_mock.assert_not_called()

# lvm devices file: enabled, image installation: True
with patch("pyanaconda.modules.storage.installation.HAVE_LVMDEVICES", new=True):
patched_conf.target.is_image = True
WriteConfigurationTask._write_lvm_devices_file(storage, tmp)
dev1.format.lvmdevices_add.assert_not_called()
dev2.format.lvmdevices_add.assert_not_called()
dev3.format.lvmdevices_add.assert_not_called()
dev4.format.lvmdevices_add.assert_not_called()
exists_mock.assert_not_called()

# lvm devices file: enabled
# lvm devices file: enabled, image installation: False
with patch("pyanaconda.modules.storage.installation.HAVE_LVMDEVICES", new=True):
patched_conf.target.is_image = False
WriteConfigurationTask._write_lvm_devices_file(storage, tmp)
dev1.format.lvmdevices_add.assert_called_once_with()
dev2.format.lvmdevices_add.assert_not_called()
Expand Down

0 comments on commit 5e9db7c

Please sign in to comment.