summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2020-07-29 10:18:47 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2020-07-29 10:19:49 +0200
commit89275bd50322e87de3d9283c85ac57022ed64fbe (patch)
tree873fe77417b170d7fc24c0878d5b7d233eaf4057 /ironic
parentebae6a40f1131f2b4602e7deddd2a8bd6382ae22 (diff)
downloadironic-89275bd50322e87de3d9283c85ac57022ed64fbe.tar.gz
AgentRAID: Account for empty results in post-configuration checks
Currently we only raise if no results are returned at all. Due to a bug apply_configuration is currently returning None, resulting in a TypeError later on. This changes help catching such situations earlier. Also provides a clearer error message that mentions RAID rather then just generic "deploying" or "cleaning". Change-Id: I5e047b6b0a00043594a93e87e09ee60b9342dbfa
Diffstat (limited to 'ironic')
-rw-r--r--ironic/drivers/modules/agent.py10
-rw-r--r--ironic/tests/unit/drivers/modules/test_agent.py11
2 files changed, 16 insertions, 5 deletions
diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py
index 08eaf0266..1466cb765 100644
--- a/ironic/drivers/modules/agent.py
+++ b/ironic/drivers/modules/agent.py
@@ -736,17 +736,17 @@ class AgentRAID(base.RAIDInterface):
"""
try:
if task.node.provision_state == states.DEPLOYWAIT:
- operation = "deploying"
result = command['command_result']['deploy_result']
else:
- operation = "cleaning"
result = command['command_result']['clean_result']
except KeyError:
+ result = None
+
+ if not result:
raise exception.IronicException(
_("Agent ramdisk didn't return a proper command result while "
- "%(operation)s %(node)s. It returned '%(result)s' after "
- "command execution.") % {'operation': operation,
- 'node': task.node.uuid,
+ "building RAID on %(node)s. It returned '%(result)s' after "
+ "command execution.") % {'node': task.node.uuid,
'result': command})
raid.update_raid_info(task.node, result)
diff --git a/ironic/tests/unit/drivers/modules/test_agent.py b/ironic/tests/unit/drivers/modules/test_agent.py
index 7c22a584b..7db79b066 100644
--- a/ironic/tests/unit/drivers/modules/test_agent.py
+++ b/ironic/tests/unit/drivers/modules/test_agent.py
@@ -1818,6 +1818,17 @@ class AgentRAIDTestCase(db_base.DbTestCase):
task, command)
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)
def test_delete_configuration(self, execute_mock):
execute_mock.return_value = states.CLEANING