From a8c1c48558b6aefa1f75c89d99bcd0111ff321f5 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 10 Apr 2024 17:05:46 +0200 Subject: [PATCH 1/2] fix: Fix recreate check for formats without labelling support Formats like LUKS or LVMPV don't support labels so we need to skip the label check in BlivetVolume._reformat. Resolves: RHEL-29874 --- library/blivet.py | 3 +++ tests/tests_volume_relabel.yml | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/library/blivet.py b/library/blivet.py index 20389ea6..18807de9 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -826,6 +826,9 @@ def _reformat(self): if ((fmt is None and self._device.format.type is None) or (fmt is not None and self._device.format.type == fmt.type)): # format is the same, no need to run reformatting + if not hasattr(self._device.format, "label"): + # not all formats support labels + return dev_label = '' if self._device.format.label is None else self._device.format.label if dev_label != fmt.label: # ...but the label has changed - schedule modification action diff --git a/tests/tests_volume_relabel.yml b/tests/tests_volume_relabel.yml index 8916b730..6624fbda 100644 --- a/tests/tests_volume_relabel.yml +++ b/tests/tests_volume_relabel.yml @@ -111,6 +111,26 @@ - name: Verify role results include_tasks: verify-role-results.yml + - name: Format the device to LVMPV which doesn't support labels + include_role: + name: linux-system-roles.storage + vars: + storage_volumes: + - name: test1 + type: disk + fs_type: lvmpv + disks: "{{ unused_disks }}" + + - name: Rerun to check we don't try to relabel preexisitng LVMPV (regression test for RHEL-29874) + include_role: + name: linux-system-roles.storage + vars: + storage_volumes: + - name: test1 + type: disk + fs_type: lvmpv + disks: "{{ unused_disks }}" + - name: Clean up include_role: name: linux-system-roles.storage From 01e09cfd9564facaa33cd7e5824ac46861ea476d Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 10 Apr 2024 17:08:20 +0200 Subject: [PATCH 2/2] fix: Fix incorrent populate call `populate()` is method of DeviceTree, not Blivet. --- library/blivet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/blivet.py b/library/blivet.py index 18807de9..d82b86b5 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -630,7 +630,7 @@ def _look_up_device(self): device.original_format._key_file = self._volume.get('encryption_key') device.original_format.passphrase = self._volume.get('encryption_password') if device.isleaf: - self._blivet.populate() + self._blivet.devicetree.populate() if not device.isleaf: device = device.children[0]