|
| 1 | +From 0df5807ead5570ab662db0e9d36e6e019b2cd850 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Doug Goldstein < [email protected]> |
| 3 | +Date: Thu, 6 Nov 2025 16:11:55 -0600 |
| 4 | +Subject: [PATCH] fix: local_link_connection inspection hook does not fail on |
| 5 | + missing port |
| 6 | + |
| 7 | +The code intended to not fail when a Port object was missing but to |
| 8 | +instead skip the handling of that node but instead there is an unhandled |
| 9 | +exception because the get_by_address() method throws PortNotFound |
| 10 | +instead of returning None when a port couldn't be found. |
| 11 | + |
| 12 | +Change-Id: I04dfa09ada7e6a9d22ba16051cb5737daf3bc668 |
| 13 | +Signed-off-by: Doug Goldstein < [email protected]> |
| 14 | +--- |
| 15 | + .../modules/inspector/hooks/local_link_connection.py | 6 ++++-- |
| 16 | + ...t-hook-local-link-connection-crash-394edb1c35354968.yaml | 6 ++++++ |
| 17 | + 2 files changed, 10 insertions(+), 2 deletions(-) |
| 18 | + create mode 100644 releasenotes/notes/inspect-hook-local-link-connection-crash-394edb1c35354968.yaml |
| 19 | + |
| 20 | +diff --git a/ironic/drivers/modules/inspector/hooks/local_link_connection.py b/ironic/drivers/modules/inspector/hooks/local_link_connection.py |
| 21 | +index a3fb9fc71..17bc82f01 100644 |
| 22 | +--- a/ironic/drivers/modules/inspector/hooks/local_link_connection.py |
| 23 | ++++ b/ironic/drivers/modules/inspector/hooks/local_link_connection.py |
| 24 | +@@ -117,8 +117,10 @@ class LocalLinkConnectionHook(base.InspectionHook): |
| 25 | + continue |
| 26 | + |
| 27 | + mac_address = iface['mac_address'] |
| 28 | +- port = ironic_port.Port.get_by_address(task.context, mac_address) |
| 29 | +- if not port: |
| 30 | ++ try: |
| 31 | ++ port = ironic_port.Port.get_by_address(task.context, |
| 32 | ++ mac_address) |
| 33 | ++ except exception.PortNotFound: |
| 34 | + LOG.debug('Skipping LLDP processing for interface %s of node ' |
| 35 | + '%s: matching port not found in Ironic.', |
| 36 | + mac_address, task.node.uuid) |
0 commit comments