From e8de78ece732bb74503c653475655cc82baaa390 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Tue, 6 Jan 2026 09:04:26 -0600 Subject: [PATCH] fix: report a better error in validate-interfaces When validate-interfaces runs if there is no interfaces key then we would just have a KeyError exception that would be logged to the node. This provides a clearer message back as to why this happened. Change-Id: I307848a9a1733ecff534ae37541e59465b4e96b7 Signed-off-by: Doug Goldstein (cherry picked from commit d56a70e8ab8c72e8f9adef1cd27a16ef45321539) --- .../drivers/modules/inspector/hooks/validate_interfaces.py | 5 +++++ .../notes/validate-interfaces-hook-49d7d6c57929a8cd.yaml | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 releasenotes/notes/validate-interfaces-hook-49d7d6c57929a8cd.yaml diff --git a/ironic/drivers/modules/inspector/hooks/validate_interfaces.py b/ironic/drivers/modules/inspector/hooks/validate_interfaces.py index 270ac904e1..870b782a15 100644 --- a/ironic/drivers/modules/inspector/hooks/validate_interfaces.py +++ b/ironic/drivers/modules/inspector/hooks/validate_interfaces.py @@ -49,6 +49,11 @@ def get_interfaces(node, inventory): result = {} pxe_mac = get_pxe_mac(inventory) + if 'interfaces' not in inventory: + raise exception.InvalidNodeInventory( + node=node.uuid, + reason=_('no interfaces present in inventory')) + for iface in inventory['interfaces']: name = iface.get('name') mac = iface.get('mac_address') diff --git a/releasenotes/notes/validate-interfaces-hook-49d7d6c57929a8cd.yaml b/releasenotes/notes/validate-interfaces-hook-49d7d6c57929a8cd.yaml new file mode 100644 index 0000000000..d9f64a39b4 --- /dev/null +++ b/releasenotes/notes/validate-interfaces-hook-49d7d6c57929a8cd.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Report a better error message than a KeyError when there are no interfaces + in the inspection data when running the validate-interfaces inspection hook.