Skip to content

Commit cd3dbdc

Browse files
committed
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
1 parent 169e33d commit cd3dbdc

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

library/blivet.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
fs_label:
111111
description: fs_label
112112
type: str
113-
default: ''
114113
fs_type:
115114
description: fs_type
116115
type: str
@@ -216,7 +215,6 @@
216215
fs_label:
217216
description: fs_label
218217
type: str
219-
default: ''
220218
fs_type:
221219
description: fs_type
222220
type: str
@@ -658,7 +656,7 @@ def _update_from_device(self, param_name):
658656
elif param_name == 'fs_type' and (self._device.format.type or self._device.format.name != get_format(None).name):
659657
self._volume['fs_type'] = self._device.format.type
660658
elif param_name == 'fs_label':
661-
self._volume['fs_label'] = getattr(self._device.format, 'label', "") or ""
659+
self._volume['fs_label'] = getattr(self._device.format, 'label', None)
662660
elif param_name == 'mount_point':
663661
self._volume['mount_point'] = getattr(self._device.format, 'mountpoint', None)
664662
elif param_name == 'disks':
@@ -2091,7 +2089,7 @@ def run_module():
20912089
encryption_luks_version=dict(type='str'),
20922090
encryption_password=dict(type='str', no_log=True),
20932091
fs_create_options=dict(type='str'),
2094-
fs_label=dict(type='str', default=''),
2092+
fs_label=dict(type='str'),
20952093
fs_type=dict(type='str'),
20962094
mount_options=dict(type='str'),
20972095
mount_point=dict(type='str'),

tests/tests_lvm_pool_shared.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
size: "{{ volume1_size }}"
128128
mount_point: "{{ mount_location1 }}"
129129
fs_type: gfs2
130-
fs_create_options: -p lock_nolock
130+
fs_create_options: -j 2 -t rhel9-1node:myfs
131131
132132
- name: Verify role results
133133
include_tasks: verify-role-results.yml
@@ -147,7 +147,7 @@
147147
size: "{{ volume1_size }}"
148148
mount_point: "{{ mount_location1 }}"
149149
fs_type: gfs2
150-
fs_create_options: -p lock_nolock
150+
fs_create_options: -j 2 -t rhel9-1node:myfs
151151

152152
- name: Verify role results
153153
include_tasks: verify-role-results.yml

tests/tests_volume_relabel.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,40 @@
7777
- name: Verify role results
7878
include_tasks: verify-role-results.yml
7979

80+
- name: Relabel without explicitly setting the label
81+
include_role:
82+
name: linux-system-roles.storage
83+
vars:
84+
storage_volumes:
85+
- name: test1
86+
type: disk
87+
mount_point: "{{ mount_location }}"
88+
fs_type: ext4
89+
disks: "{{ unused_disks }}"
90+
91+
- name: Check for default value
92+
assert:
93+
that: not blivet_output.changed
94+
msg: "Volume relabeling doesn't preserve existing label."
95+
96+
- name: Verify role results
97+
include_tasks: verify-role-results.yml
98+
99+
- name: Remove label
100+
include_role:
101+
name: linux-system-roles.storage
102+
vars:
103+
storage_volumes:
104+
- name: test1
105+
type: disk
106+
mount_point: "{{ mount_location }}"
107+
fs_type: ext4
108+
disks: "{{ unused_disks }}"
109+
fs_label: ""
110+
111+
- name: Verify role results
112+
include_tasks: verify-role-results.yml
113+
80114
- name: Clean up
81115
include_role:
82116
name: linux-system-roles.storage

0 commit comments

Comments
 (0)