Browse Source

Merge "Skip nic numa_node discovery if it's not assigned to a numa_node" into stable/train

tags/5.0.1
Zuul 4 weeks ago
parent
commit
e6bfd8f485
3 changed files with 14 additions and 7 deletions
  1. +2
    -1
      ironic_python_agent/numa_inspector.py
  2. +6
    -6
      ironic_python_agent/tests/unit/test_numa_inspector.py
  3. +6
    -0
      releasenotes/notes/fix-nic-without-numa-node-b401f97c46afa4a1.yaml

+ 2
- 1
ironic_python_agent/numa_inspector.py View File

@@ -193,7 +193,8 @@ def get_nodes_nics_info(nic_device_path):
{'nic_device_path': nic_device_path})
raise errors.IncompatibleNumaFormatError(msg)
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
try:
with open(os.path.join(nic_device_path, nic_dir, 'device',

+ 6
- 6
ironic_python_agent/tests/unit/test_numa_inspector.py View File

@@ -303,12 +303,12 @@ class TestGetNumaTopologyInfo(base.IronicAgentTest):
numa_insp.get_nodes_cores_info,
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)
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']
mock_listdir.return_value = nic_dirs
mock_isdir.return_value = True
mock_isfile.return_value = True
reads = ['0', '1']
expected_nicsinfo = [{'name': 'enp0s01', 'numa_node': 0},
{'name': 'enp0s02', 'numa_node': 1}]
@@ -319,12 +319,12 @@ class TestGetNumaTopologyInfo(base.IronicAgentTest):
nics = numa_insp.get_nodes_nics_info('/sys/class/net/')
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)
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']
mock_listdir.return_value = nic_dirs
mock_isdir.return_value = True
mock_isfile.return_value = True
reads = ['0', IOError]
mock_open = mock.mock_open()
with mock.patch('six.moves.builtins.open', mock_open):

+ 6
- 0
releasenotes/notes/fix-nic-without-numa-node-b401f97c46afa4a1.yaml View File

@@ -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…
Cancel
Save