fix: agent inspection hooks failure does not clean up

When the using the agent inspector interface and an exception happens
during execution of the hook, the node is not cleaned up resulting in
stale Neutron ports and ramdisk files.

Closes-Bug: 2135265
Change-Id: I69ceec12fc0beea586176a768d864a22261cdb93
Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
This commit is contained in:
Doug Goldstein 2025-12-12 15:23:57 -06:00
parent 42883161cb
commit 30113a4c23
No known key found for this signature in database
2 changed files with 17 additions and 3 deletions

View file

@ -84,9 +84,16 @@ class AgentInspect(common.Common):
:param inventory: hardware inventory from the node.
:param plugin_data: optional plugin-specific data.
"""
# Run the inspection hooks
inspect_utils.run_inspection_hooks(task, inventory, plugin_data,
self.hooks, _store_logs)
try:
# Run the inspection hooks
inspect_utils.run_inspection_hooks(task, inventory, plugin_data,
self.hooks, _store_logs)
except Exception as exc:
error = _("failed to run inspection hooks: %s") % exc
common.inspection_error_handler(task, error, raise_exc=True,
clean_up=True)
if CONF.agent.deploy_logs_collect == 'always':
_store_logs(plugin_data, task.node)
common.clean_up(task, finish=False, always_power_off=True)

View file

@ -0,0 +1,7 @@
---
fixes:
- |
[`Bug 2135265 <https://bugs.launchpad.net/ironic/+bug/2135265>`_]
Fixes an issue where an exception in one of the inspection hooks when
using the agent inspector interface would result in the node not being
cleaned up.