Skip to content

Commit a99bf27

Browse files
committed
SoftwareRAID: Enable skipping RAIDS
Extend the ability to skip disks to RAID devices This allows users to specify the volume name of a logical device in the skip list which is then not cleaned or created again during the create/apply configuration phase The volume name can be specified in target raid config provided the change https://review.opendev.org/c/openstack/ironic-python-agent/+/853182/ passes Story: 2010233 Change-Id: Ib9290a97519bc48e585e1bafb0b60cc14e621e0f
1 parent ed6a8d2 commit a99bf27

File tree

8 files changed

+750
-59
lines changed

8 files changed

+750
-59
lines changed

doc/source/admin/hardware_managers.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ containing hints to identify the drives. For example::
121121
'skip_block_devices': [{'name': '/dev/vda', 'vendor': '0x1af4'}]
122122

123123

124+
To prevent software RAID devices from being deleted, put their volume name
125+
(defined in the ``target_raid_config``) to the list.
126+
127+
Note: one dictionary with one value for each of the logical disks.
128+
For example::
129+
130+
'skip_block_devices': [{'volume_name': 'large'}, {'volume_name': 'temp'}]
131+
132+
124133
Shared Disk Cluster Filesystems
125134
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126135

ironic_python_agent/hardware.py

Lines changed: 189 additions & 55 deletions
Large diffs are not rendered by default.

ironic_python_agent/raid_utils.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,44 @@ def get_next_free_raid_device():
267267
name = f'/dev/md{idx}'
268268
if name not in names:
269269
return name
270-
271270
raise errors.SoftwareRAIDError("No free md (RAID) devices are left")
272271

273272

273+
def get_volume_name_of_raid_device(raid_device):
274+
"""Get the volume name of a RAID device
275+
276+
:param raid_device: A Software RAID block device name.
277+
:returns: volume name of the device, or None
278+
"""
279+
if not raid_device:
280+
return None
281+
try:
282+
out, _ = utils.execute('mdadm', '--detail', raid_device,
283+
use_standard_locale=True)
284+
except processutils.ProcessExecutionError as e:
285+
LOG.warning('Could not retrieve the volume name of %(dev)s: %(err)s',
286+
{'dev': raid_device, 'err': e})
287+
return None
288+
lines = out.splitlines()
289+
for line in lines:
290+
if re.search(r'Name', line) is not None:
291+
split_array = line.split(':')
292+
# expecting format:
293+
# Name : <host>:name (optional comment)
294+
if len(split_array) == 3:
295+
candidate = split_array[2]
296+
else:
297+
return None
298+
# if name is followed by some other text
299+
# such as (local to host <domain>) remove
300+
# everything after " "
301+
if " " in candidate:
302+
candidate = candidate.split(" ")[0]
303+
volume_name = candidate
304+
return volume_name
305+
return None
306+
307+
274308
# TODO(rg): handle PreP boot parts relocation as well
275309
def prepare_boot_partitions_for_softraid(device, holders, efi_part,
276310
target_boot_mode):

ironic_python_agent/tests/unit/samples/hardware_samples.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,61 @@
10311031
1 259 3 1 active sync /dev/nvme1n1p1
10321032
""")
10331033

1034+
MDADM_DETAIL_OUTPUT_VOLUME_NAME = ("""/dev/md0:
1035+
Version : 1.0
1036+
Creation Time : Fri Feb 15 12:37:44 2019
1037+
Raid Level : raid1
1038+
Array Size : 1048512 (1023.94 MiB 1073.68 MB)
1039+
Used Dev Size : 1048512 (1023.94 MiB 1073.68 MB)
1040+
Raid Devices : 2
1041+
Total Devices : 2
1042+
Persistence : Superblock is persistent
1043+
1044+
Update Time : Fri Feb 15 12:38:02 2019
1045+
State : clean
1046+
Active Devices : 2
1047+
Working Devices : 2
1048+
Failed Devices : 0
1049+
Spare Devices : 0
1050+
1051+
Consistency Policy : resync
1052+
1053+
Name : abc.xyz.com:this_name (local to host abc.xyz.com)
1054+
UUID : 83143055:2781ddf5:2c8f44c7:9b45d92e
1055+
Events : 17
1056+
1057+
Number Major Minor RaidDevice State
1058+
0 253 64 0 active sync /dev/vde1
1059+
1 253 80 1 active sync /dev/vdf1
1060+
""")
1061+
1062+
MDADM_DETAIL_OUTPUT_VOLUME_NAME_INVALID = ("""/dev/md0:
1063+
Version : 1.0
1064+
Creation Time : Fri Feb 15 12:37:44 2019
1065+
Raid Level : raid1
1066+
Array Size : 1048512 (1023.94 MiB 1073.68 MB)
1067+
Used Dev Size : 1048512 (1023.94 MiB 1073.68 MB)
1068+
Raid Devices : 2
1069+
Total Devices : 2
1070+
Persistence : Superblock is persistent
1071+
1072+
Update Time : Fri Feb 15 12:38:02 2019
1073+
State : clean
1074+
Active Devices : 2
1075+
Working Devices : 2
1076+
Failed Devices : 0
1077+
Spare Devices : 0
1078+
1079+
Consistency Policy : resync
1080+
1081+
UUID : 83143055:2781ddf5:2c8f44c7:9b45d92e
1082+
Events : 17
1083+
1084+
Number Major Minor RaidDevice State
1085+
0 253 64 0 active sync /dev/vde1
1086+
1 253 80 1 active sync /dev/vdf1
1087+
""")
1088+
10341089
MDADM_DETAIL_OUTPUT_BROKEN_RAID0 = ("""/dev/md126:
10351090
Version : 1.2
10361091
Raid Level : raid0

0 commit comments

Comments
 (0)