Merge "AgentRAID: Account for empty results in post-configuration checks"

This commit is contained in:
Zuul 2020-07-30 10:06:29 +00:00 committed by Gerrit Code Review
commit 08617ee716
2 changed files with 16 additions and 5 deletions

View File

@ -736,17 +736,17 @@ class AgentRAID(base.RAIDInterface):
""" """
try: try:
if task.node.provision_state == states.DEPLOYWAIT: if task.node.provision_state == states.DEPLOYWAIT:
operation = "deploying"
result = command['command_result']['deploy_result'] result = command['command_result']['deploy_result']
else: else:
operation = "cleaning"
result = command['command_result']['clean_result'] result = command['command_result']['clean_result']
except KeyError: except KeyError:
result = None
if not result:
raise exception.IronicException( raise exception.IronicException(
_("Agent ramdisk didn't return a proper command result while " _("Agent ramdisk didn't return a proper command result while "
"%(operation)s %(node)s. It returned '%(result)s' after " "building RAID on %(node)s. It returned '%(result)s' after "
"command execution.") % {'operation': operation, "command execution.") % {'node': task.node.uuid,
'node': task.node.uuid,
'result': command}) 'result': command})
raid.update_raid_info(task.node, result) raid.update_raid_info(task.node, result)

View File

@ -1818,6 +1818,17 @@ class AgentRAIDTestCase(db_base.DbTestCase):
task, command) task, command)
self.assertFalse(update_raid_info_mock.called) self.assertFalse(update_raid_info_mock.called)
@mock.patch.object(raid, 'update_raid_info', autospec=True)
def test__create_configuration_final_bad_command_result2(
self, update_raid_info_mock):
command = {'command_result': {'deploy_result': None}}
with task_manager.acquire(self.context, self.node.uuid) as task:
raid_mgmt = agent.AgentRAID
self.assertRaises(exception.IronicException,
raid_mgmt._create_configuration_final,
task, command)
self.assertFalse(update_raid_info_mock.called)
@mock.patch.object(agent_base, 'execute_step', autospec=True) @mock.patch.object(agent_base, 'execute_step', autospec=True)
def test_delete_configuration(self, execute_mock): def test_delete_configuration(self, execute_mock):
execute_mock.return_value = states.CLEANING execute_mock.return_value = states.CLEANING