ironic: fix logging of validation errors

When validation of the node fails, since switching to the SDK the
address of the ValidationResult object is displayed instead of the
actual message. This has been broken since patch
Ibb5b168ee0944463b996e96f033bd3dfb498e304.

Closes-Bug: 2100009
Change-Id: I8fbdaadd125ece6a3050b2fbb772a7bd5d7e5304
Signed-off-by: Doug Goldstein <cardoe@cardoe.com>
This commit is contained in:
Doug Goldstein
2025-02-17 17:19:16 -06:00
parent 12bc65f942
commit 37888e875f
3 changed files with 23 additions and 7 deletions

View File

@@ -1582,15 +1582,18 @@ class IronicDriverTestCase(test.NoDBTestCase):
self.mock_conn.validate_node.return_value = \
ironic_utils.get_test_validation(
power=_node.ValidationResult(result=False, reason=None),
power=_node.ValidationResult(result=False, reason='OVERVOLT'),
deploy=_node.ValidationResult(result=False, reason=None),
storage=_node.ValidationResult(result=False, reason=None),
storage=_node.ValidationResult(result=True, reason=None),
)
self.mock_conn.get_node.return_value = node
image_meta = ironic_utils.get_test_image_meta()
self.assertRaises(exception.ValidationError, self.driver.spawn,
self.ctx, instance, image_meta, [], None, {})
msgre = '.*deploy: None, power: OVERVOLT, storage: No Error.*'
self.assertRaisesRegex(exception.ValidationError, msgre,
self.driver.spawn, self.ctx, instance, image_meta,
[], None, {})
self.mock_conn.get_node.assert_called_once_with(
node_id, fields=ironic_driver._NODE_FIELDS)
mock_avti.assert_called_once_with(self.ctx, instance, None)

View File

@@ -1213,14 +1213,20 @@ class IronicDriver(virt_driver.ComputeDriver):
):
# something is wrong. undo what we have done
self._cleanup_deploy(node, instance, network_info)
deploy_msg = ("No Error" if validate_chk['deploy'].result
else validate_chk['deploy'].reason)
power_msg = ("No Error" if validate_chk['power'].result
else validate_chk['power'].reason)
storage_msg = ("No Error" if validate_chk['storage'].result
else validate_chk['storage'].reason)
raise exception.ValidationError(_(
"Ironic node: %(id)s failed to validate. "
"(deploy: %(deploy)s, power: %(power)s, "
"storage: %(storage)s)")
% {'id': node.id,
'deploy': validate_chk['deploy'],
'power': validate_chk['power'],
'storage': validate_chk['storage']})
'deploy': deploy_msg,
'power': power_msg,
'storage': storage_msg})
# Config drive
configdrive_value = None

View File

@@ -0,0 +1,7 @@
---
fixes:
- |
Fix displaying the reason messages from the Ironic validate node operation that
is called just before the instance is deployed on the bare metal node. The
message from Ironic is now correctly logged.
Fixes `bug 2100009 <https://bugs.launchpad.net/nova/+bug/2100009>_`.