Allow clean_configuration to run against full-device arrays
At the moment, it is not possible for Ironic to clean up a RAID array that is built from an entire device. This patch allows it to do so by overriding the behaviour of attempting to find the device name if the device names does not end with a number and is a real block device. Story: #2008663 Task: #41948 Change-Id: I66b0990acaec45b1635795563987b99f9fa04ac7
This commit is contained in:
parent
6ea3aff8d6
commit
ab267aabdd
@ -23,6 +23,7 @@ import os
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import stat
|
||||
import time
|
||||
|
||||
from ironic_lib import disk_utils
|
||||
@ -262,6 +263,13 @@ def get_holder_disks(raid_device):
|
||||
holder_parts += device
|
||||
|
||||
for part in holder_parts:
|
||||
# NOTE(mnaser): If the last character is not a digit and it is a valid
|
||||
# device, this means that instead of a partition, it's a
|
||||
# entire device which is part of this RAID array.
|
||||
if (not part[-1].isdigit() and os.path.exists(part)
|
||||
and stat.S_ISBLK(os.stat(part).st_mode)):
|
||||
holder_disks.append(part)
|
||||
continue
|
||||
|
||||
device = utils.extract_device(part)
|
||||
if not device:
|
||||
|
@ -715,6 +715,34 @@ Consistency Policy : resync
|
||||
1 253 80 1 active sync /dev/vdf1
|
||||
""")
|
||||
|
||||
MDADM_DETAIL_OUTPUT_WHOLE_DEVICE = ("""/dev/md0:
|
||||
Version : 1.0
|
||||
Creation Time : Fri Feb 15 12:37:44 2019
|
||||
Raid Level : raid1
|
||||
Array Size : 1048512 (1023.94 MiB 1073.68 MB)
|
||||
Used Dev Size : 1048512 (1023.94 MiB 1073.68 MB)
|
||||
Raid Devices : 2
|
||||
Total Devices : 2
|
||||
Persistence : Superblock is persistent
|
||||
|
||||
Update Time : Fri Feb 15 12:38:02 2019
|
||||
State : clean
|
||||
Active Devices : 2
|
||||
Working Devices : 2
|
||||
Failed Devices : 0
|
||||
Spare Devices : 0
|
||||
|
||||
Consistency Policy : resync
|
||||
|
||||
Name : abc.xyz.com:0 (local to host abc.xyz.com)
|
||||
UUID : 83143055:2781ddf5:2c8f44c7:9b45d92e
|
||||
Events : 17
|
||||
|
||||
Number Major Minor RaidDevice State
|
||||
0 253 64 0 active sync /dev/vde
|
||||
1 253 80 1 active sync /dev/vdf
|
||||
""")
|
||||
|
||||
MDADM_DETAIL_OUTPUT_NVME = ("""/dev/md0:
|
||||
Version : 1.2
|
||||
Creation Time : Wed Aug 7 13:47:27 2019
|
||||
|
@ -15,6 +15,7 @@
|
||||
import binascii
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
@ -3525,6 +3526,19 @@ class TestGenericHardwareManager(base.IronicAgentTest):
|
||||
holder_disks = hardware.get_holder_disks('/dev/md0')
|
||||
self.assertEqual(['/dev/vde', '/dev/vdf'], holder_disks)
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
@mock.patch.object(os.path, 'exists', autospec=True)
|
||||
@mock.patch.object(os, 'stat', autospec=True)
|
||||
def test_get_holder_disks_with_whole_device(self, mocked_stat,
|
||||
mocked_exists,
|
||||
mocked_execute):
|
||||
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT_WHOLE_DEVICE,
|
||||
'')]
|
||||
mocked_exists.return_value = True
|
||||
mocked_stat.return_value.st_mode = stat.S_IFBLK
|
||||
holder_disks = hardware.get_holder_disks('/dev/md0')
|
||||
self.assertEqual(['/dev/vde', '/dev/vdf'], holder_disks)
|
||||
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
def test_get_holder_disks_with_nvme(self, mocked_execute):
|
||||
mocked_execute.side_effect = [(hws.MDADM_DETAIL_OUTPUT_NVME, '')]
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- IPA will now successfully clean configuration when it encounters a software
|
||||
RAID array that was previously created using entire devices instead of
|
||||
partitions.
|
Loading…
x
Reference in New Issue
Block a user