From cd3dbdc6991a917caa5da3a2b71fa5fd9ec4651b Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Wed, 24 Jan 2024 16:52:49 +0100 Subject: [PATCH] fix: Do not set default value for fs_label For existing devices we want to read the default value from the device instead of trying to reset it to default/empty label when the fs_label attribute is not set. Related: #417 --- library/blivet.py | 6 ++---- tests/tests_lvm_pool_shared.yml | 4 ++-- tests/tests_volume_relabel.yml | 34 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/library/blivet.py b/library/blivet.py index 5f2af33c..8eb506c6 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -110,7 +110,6 @@ fs_label: description: fs_label type: str - default: '' fs_type: description: fs_type type: str @@ -216,7 +215,6 @@ fs_label: description: fs_label type: str - default: '' fs_type: description: fs_type type: str @@ -658,7 +656,7 @@ def _update_from_device(self, param_name): elif param_name == 'fs_type' and (self._device.format.type or self._device.format.name != get_format(None).name): self._volume['fs_type'] = self._device.format.type elif param_name == 'fs_label': - self._volume['fs_label'] = getattr(self._device.format, 'label', "") or "" + self._volume['fs_label'] = getattr(self._device.format, 'label', None) elif param_name == 'mount_point': self._volume['mount_point'] = getattr(self._device.format, 'mountpoint', None) elif param_name == 'disks': @@ -2091,7 +2089,7 @@ def run_module(): encryption_luks_version=dict(type='str'), encryption_password=dict(type='str', no_log=True), fs_create_options=dict(type='str'), - fs_label=dict(type='str', default=''), + fs_label=dict(type='str'), fs_type=dict(type='str'), mount_options=dict(type='str'), mount_point=dict(type='str'), diff --git a/tests/tests_lvm_pool_shared.yml b/tests/tests_lvm_pool_shared.yml index e391f277..5e900963 100644 --- a/tests/tests_lvm_pool_shared.yml +++ b/tests/tests_lvm_pool_shared.yml @@ -127,7 +127,7 @@ size: "{{ volume1_size }}" mount_point: "{{ mount_location1 }}" fs_type: gfs2 - fs_create_options: -p lock_nolock + fs_create_options: -j 2 -t rhel9-1node:myfs - name: Verify role results include_tasks: verify-role-results.yml @@ -147,7 +147,7 @@ size: "{{ volume1_size }}" mount_point: "{{ mount_location1 }}" fs_type: gfs2 - fs_create_options: -p lock_nolock + fs_create_options: -j 2 -t rhel9-1node:myfs - name: Verify role results include_tasks: verify-role-results.yml diff --git a/tests/tests_volume_relabel.yml b/tests/tests_volume_relabel.yml index 46525da1..8916b730 100644 --- a/tests/tests_volume_relabel.yml +++ b/tests/tests_volume_relabel.yml @@ -77,6 +77,40 @@ - name: Verify role results include_tasks: verify-role-results.yml + - name: Relabel without explicitly setting the label + include_role: + name: linux-system-roles.storage + vars: + storage_volumes: + - name: test1 + type: disk + mount_point: "{{ mount_location }}" + fs_type: ext4 + disks: "{{ unused_disks }}" + + - name: Check for default value + assert: + that: not blivet_output.changed + msg: "Volume relabeling doesn't preserve existing label." + + - name: Verify role results + include_tasks: verify-role-results.yml + + - name: Remove label + include_role: + name: linux-system-roles.storage + vars: + storage_volumes: + - name: test1 + type: disk + mount_point: "{{ mount_location }}" + fs_type: ext4 + disks: "{{ unused_disks }}" + fs_label: "" + + - name: Verify role results + include_tasks: verify-role-results.yml + - name: Clean up include_role: name: linux-system-roles.storage