Make validation failure on node deploy a 4XX code
Missing information and other validation issues with instance_info is a user error and should be a 4XX code HTTP response, currently Ironic responds with a 5XX code indicating something has gone wrong with the service. Change-Id: If76e2aba97e0ed9fa63ad3c411ed92969164d3dc Story: #2001983 Task: #19600
This commit is contained in:
parent
02d8fa1393
commit
6ff9a6b14c
@ -104,6 +104,8 @@ class IronicException(Exception):
|
|||||||
self.kwargs['code'] = self.code
|
self.kwargs['code'] = self.code
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
self.code = int(kwargs['code'])
|
||||||
|
|
||||||
if not message:
|
if not message:
|
||||||
try:
|
try:
|
||||||
|
@ -827,7 +827,7 @@ class ConductorManager(base_manager.BaseConductorManager):
|
|||||||
raise exception.InstanceDeployFailure(
|
raise exception.InstanceDeployFailure(
|
||||||
_("Failed to validate deploy or power info for node "
|
_("Failed to validate deploy or power info for node "
|
||||||
"%(node_uuid)s. Error: %(msg)s") %
|
"%(node_uuid)s. Error: %(msg)s") %
|
||||||
{'node_uuid': node.uuid, 'msg': e})
|
{'node_uuid': node.uuid, 'msg': e}, code=e.code)
|
||||||
|
|
||||||
LOG.debug("do_node_deploy Calling event: %(event)s for node: "
|
LOG.debug("do_node_deploy Calling event: %(event)s for node: "
|
||||||
"%(node)s", {'event': event, 'node': node.uuid})
|
"%(node)s", {'event': event, 'node': node.uuid})
|
||||||
|
@ -1218,6 +1218,7 @@ class ServiceDoNodeDeployTestCase(mgr_utils.ServiceSetUpMixin,
|
|||||||
self.context, node.uuid)
|
self.context, node.uuid)
|
||||||
# Compare true exception hidden by @messaging.expected_exceptions
|
# Compare true exception hidden by @messaging.expected_exceptions
|
||||||
self.assertEqual(exception.InstanceDeployFailure, exc.exc_info[0])
|
self.assertEqual(exception.InstanceDeployFailure, exc.exc_info[0])
|
||||||
|
self.assertEqual(exc.exc_info[1].code, 400)
|
||||||
# Check the message of InstanceDeployFailure. In a
|
# Check the message of InstanceDeployFailure. In a
|
||||||
# messaging.rpc.ExpectedException sys.exc_info() is stored in exc_info
|
# messaging.rpc.ExpectedException sys.exc_info() is stored in exc_info
|
||||||
# in the exception object. So InstanceDeployFailure will be in
|
# in the exception object. So InstanceDeployFailure will be in
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes the HTTP response code for a validation failure when attempting to
|
||||||
|
move an ironic node to the active state. Validation failure in this
|
||||||
|
scenario now responses with a 400 status code correctly indicating a user
|
||||||
|
input error.
|
Loading…
Reference in New Issue
Block a user