Skip nic numa_node discovery if it's not assigned to a numa_node
In some rare case, such as a VM with virtual numa node, nics might not be in a numa node and this breaks numa-topology discovery. Change-Id: I52f52119a5f3175b1723fde291eb26d4f86c8223 Story: 2007105 Task: 38151
This commit is contained in:
parent
1b20dd9b96
commit
a1a121fbf8
@ -193,7 +193,8 @@ def get_nodes_nics_info(nic_device_path):
|
|||||||
{'nic_device_path': nic_device_path})
|
{'nic_device_path': nic_device_path})
|
||||||
raise errors.IncompatibleNumaFormatError(msg)
|
raise errors.IncompatibleNumaFormatError(msg)
|
||||||
for nic_dir in os.listdir(nic_device_path):
|
for nic_dir in os.listdir(nic_device_path):
|
||||||
if not os.path.isdir(os.path.join(nic_device_path, nic_dir, 'device')):
|
if not os.path.isfile(os.path.join(nic_device_path,
|
||||||
|
nic_dir, 'device', 'numa_node')):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(nic_device_path, nic_dir, 'device',
|
with open(os.path.join(nic_device_path, nic_dir, 'device',
|
||||||
|
@ -303,12 +303,12 @@ class TestGetNumaTopologyInfo(base.IronicAgentTest):
|
|||||||
numa_insp.get_nodes_cores_info,
|
numa_insp.get_nodes_cores_info,
|
||||||
numa_node_dirs)
|
numa_node_dirs)
|
||||||
|
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True)
|
@mock.patch.object(os.path, 'isfile', autospec=True)
|
||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
def test_get_nodes_nics_info(self, mock_listdir, mock_isdir):
|
def test_get_nodes_nics_info(self, mock_listdir, mock_isfile):
|
||||||
nic_dirs = ['enp0s01', 'enp0s02']
|
nic_dirs = ['enp0s01', 'enp0s02']
|
||||||
mock_listdir.return_value = nic_dirs
|
mock_listdir.return_value = nic_dirs
|
||||||
mock_isdir.return_value = True
|
mock_isfile.return_value = True
|
||||||
reads = ['0', '1']
|
reads = ['0', '1']
|
||||||
expected_nicsinfo = [{'name': 'enp0s01', 'numa_node': 0},
|
expected_nicsinfo = [{'name': 'enp0s01', 'numa_node': 0},
|
||||||
{'name': 'enp0s02', 'numa_node': 1}]
|
{'name': 'enp0s02', 'numa_node': 1}]
|
||||||
@ -319,12 +319,12 @@ class TestGetNumaTopologyInfo(base.IronicAgentTest):
|
|||||||
nics = numa_insp.get_nodes_nics_info('/sys/class/net/')
|
nics = numa_insp.get_nodes_nics_info('/sys/class/net/')
|
||||||
self.assertListEqual(expected_nicsinfo, nics)
|
self.assertListEqual(expected_nicsinfo, nics)
|
||||||
|
|
||||||
@mock.patch.object(os.path, 'isdir', autospec=True)
|
@mock.patch.object(os.path, 'isfile', autospec=True)
|
||||||
@mock.patch.object(os, 'listdir', autospec=True)
|
@mock.patch.object(os, 'listdir', autospec=True)
|
||||||
def test_bad_nodes_nics_info(self, mock_listdir, mock_isdir):
|
def test_bad_nodes_nics_info(self, mock_listdir, mock_isfile):
|
||||||
nic_dirs = ['enp0s01', 'enp0s02']
|
nic_dirs = ['enp0s01', 'enp0s02']
|
||||||
mock_listdir.return_value = nic_dirs
|
mock_listdir.return_value = nic_dirs
|
||||||
mock_isdir.return_value = True
|
mock_isfile.return_value = True
|
||||||
reads = ['0', IOError]
|
reads = ['0', IOError]
|
||||||
mock_open = mock.mock_open()
|
mock_open = mock.mock_open()
|
||||||
with mock.patch('builtins.open', mock_open):
|
with mock.patch('builtins.open', mock_open):
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Skips NIC numa_node discovery if it's not assigned to a numa_node as
|
||||||
|
in some rare case, such as a VM with virtual NUMA node, NICs might
|
||||||
|
not be in a NUMA node and this breaks numa-topology discovery.
|
Loading…
Reference in New Issue
Block a user