Merge "Fix inspection IB port client-id"

This commit is contained in:
Zuul
2025-11-15 04:08:14 +00:00
committed by Gerrit Code Review
4 changed files with 56 additions and 3 deletions

View File

@@ -73,6 +73,8 @@ def update_ports(task, all_interfaces, valid_macs):
pxe_macs = {iface['mac_address'] for iface in all_interfaces.values()
if iface['pxe_enabled']}
client_ids = {iface['mac_address']: iface.get('client_id')
for iface in all_interfaces.values()}
for port in objects.Port.list_by_node_id(task.context, task.node.id):
if expected_macs and port.address not in expected_macs:
@@ -82,7 +84,9 @@ def update_ports(task, all_interfaces, valid_macs):
{'port': port.uuid, 'mac': port.address,
'node': task.node.uuid, 'expected': expected_str})
port.destroy()
elif CONF.inspector.update_pxe_enabled:
continue
if CONF.inspector.update_pxe_enabled:
pxe_enabled = port.address in pxe_macs
if pxe_enabled != port.pxe_enabled:
LOG.debug("Changing pxe_enabled=%(val)s on port %(port)s "
@@ -91,3 +95,15 @@ def update_ports(task, all_interfaces, valid_macs):
'node': task.node.uuid})
port.pxe_enabled = pxe_enabled
port.save()
new_client_id = client_ids.get(port.address)
current_client_id = port.extra.get('client-id')
# some sources can't find client_id, so ignore if not found
if new_client_id and new_client_id != current_client_id:
LOG.debug("Changing client-id from %(current)s to "
"%(new)s on port %(port)s of node %(node)s",
{'port': port.address, 'current': current_client_id,
'new': new_client_id, 'node': task.node.uuid})
port.extra['client-id'] = new_client_id
port._changed_fields.add('extra')
port.save()

View File

@@ -32,7 +32,7 @@ class AddPortsTestCase(db_base.DbTestCase):
self.node = obj_utils.create_test_node(self.context,
inspect_interface='agent')
self.interfaces = {key: value.copy() for key, value in _VALID.items()
if key not in ('lo', 'em4')}
if key not in ('lo', 'em4', 'ib0')}
self.macs = {
_PXE_INTERFACE,
'11:11:11:11:11:11',
@@ -74,6 +74,7 @@ class UpdatePortsTestCase(db_base.DbTestCase):
'11:11:11:11:11:11',
'22:22:22:22:22:22',
'33:33:33:33:33:33',
'55:55:55:55:55:55',
}
self.present_macs = {i['mac_address'] for i in _VALID.values()}
self.extra_mac = '00:11:00:11:00:11'
@@ -123,3 +124,14 @@ class UpdatePortsTestCase(db_base.DbTestCase):
{port.address: port.pxe_enabled for port in ports},
# Extra port removed, pxe_enabled updated
{mac: (mac == _PXE_INTERFACE) for mac in self.present_macs})
def test_update_client_id(self):
with task_manager.acquire(self.context, self.node.id) as task:
ports_hook.update_ports(task, _VALID, self.macs)
ports = objects.Port.list_by_node_id(self.context, self.node.id)
expected_client_ids = {mac: {} for mac in self.all_macs}
ib_mac = '55:55:55:55:55:55'
expected_client_ids[ib_mac] = {'client-id': 'fake-client-id'}
self.assertEqual(
{port.address: port.extra for port in ports},
expected_client_ids)

View File

@@ -71,6 +71,15 @@ _INVENTORY = {
'ipv6_address': None,
'has_carrier': False,
},
{
'name': 'ib0',
'mac_address': '55:55:55:55:55:55',
'ipv4_address': None,
'ipv6_address': None,
'has_carrier': False,
'pxe_enabled': False,
'client_id': 'fake-client-id',
},
],
}
@@ -124,6 +133,15 @@ _VALID = {
'has_carrier': False,
'pxe_enabled': False,
},
'ib0': {
'name': 'ib0',
'mac_address': '55:55:55:55:55:55',
'ipv4_address': None,
'ipv6_address': None,
'has_carrier': False,
'pxe_enabled': False,
'client_id': 'fake-client-id',
},
}
@@ -194,7 +212,7 @@ class ValidateInterfacesTestCase(db_base.DbTestCase):
def test_active_interfaces(self):
CONF.set_override('add_ports', 'active', group='inspector')
expected = {key: value.copy() for key, value in _VALID.items()
if key not in ('lo', 'em4')}
if key not in ('lo', 'em4', 'ib0')}
result = validate_interfaces_hook.validate_interfaces(
self.node, self.inventory, self.interfaces)
self.assertEqual(expected, result)

View File

@@ -0,0 +1,7 @@
---
fixes:
- |
Fixes an issue where handling of introspection data was failing
to update process InfiniBand ``client-id`` values. When discovered,
InfiniBand ports should have their ``client-id`` values recorded
which enables proper network boot handling with InfiniBand.