diff options
author | Mohammed Naser <mnaser@vexxhost.com> | 2021-03-23 12:28:33 -0400 |
---|---|---|
committer | Mohammed Naser <mnaser@vexxhost.com> | 2021-03-23 16:34:41 -0400 |
commit | 8cfde7447005a460a60f6d99385b32867a9391bf (patch) | |
tree | c567853f46b29c118c4a2bacfca61132834e4d6a | |
parent | f5dc3a0698ba816d4adf37a1eddf4415a609f924 (diff) | |
download | ironic-8cfde7447005a460a60f6d99385b32867a9391bf.tar.gz |
Allow running RAID cleaning steps with in-band cleaning
In I3b647e39982c0a98abac7b0a7c1c60215d6db4f2, the change
allowed users to set priorities for create and delete config
however it was not set in the right place because the steps live
in the `raid` interface.
This patch introduces a get_clean_steps for the RAID interface
which gets all the steps and the correct overrides. This has been
tested to work in a local environment.
Change-Id: I5138ec9daf27affc28647dd83c79a867c9be6f3d
-rw-r--r-- | ironic/drivers/modules/agent.py | 18 | ||||
-rw-r--r-- | ironic/drivers/modules/agent_base.py | 2 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_agent.py | 31 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_iscsi_deploy.py | 4 |
4 files changed, 38 insertions, 17 deletions
diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py index b84eb6d95..48779b963 100644 --- a/ironic/drivers/modules/agent.py +++ b/ironic/drivers/modules/agent.py @@ -666,6 +666,24 @@ class AgentRAID(base.RAIDInterface): """Return the properties of the interface.""" return {} + @METRICS.timer('AgentRAID.get_clean_steps') + def get_clean_steps(self, task): + """Get the list of clean steps from the agent. + + :param task: a TaskManager object containing the node + :raises NodeCleaningFailure: if the clean steps are not yet + available (cached), for example, when a node has just been + enrolled and has not been cleaned yet. + :returns: A list of clean step dictionaries + """ + new_priorities = { + 'delete_configuration': CONF.deploy.delete_configuration_priority, + 'create_configuration': CONF.deploy.create_configuration_priority + } + return agent_base.get_steps( + task, 'clean', interface='raid', + override_priorities=new_priorities) + @METRICS.timer('AgentRAID.get_deploy_steps') def get_deploy_steps(self, task): """Get the list of deploy steps from the agent. diff --git a/ironic/drivers/modules/agent_base.py b/ironic/drivers/modules/agent_base.py index 1fca38acd..ef2fe307c 100644 --- a/ironic/drivers/modules/agent_base.py +++ b/ironic/drivers/modules/agent_base.py @@ -852,8 +852,6 @@ class AgentDeployMixin(HeartbeatMixin, AgentOobStepsMixin): 'erase_devices': CONF.deploy.erase_devices_priority, 'erase_devices_metadata': CONF.deploy.erase_devices_metadata_priority, - 'delete_configuration': CONF.deploy.delete_configuration_priority, - 'create_configuration': CONF.deploy.create_configuration_priority } return get_steps( task, 'clean', interface='deploy', diff --git a/ironic/tests/unit/drivers/modules/test_agent.py b/ironic/tests/unit/drivers/modules/test_agent.py index 8b50b33e4..ef3d77476 100644 --- a/ironic/tests/unit/drivers/modules/test_agent.py +++ b/ironic/tests/unit/drivers/modules/test_agent.py @@ -1163,21 +1163,16 @@ class TestAgentDeploy(db_base.DbTestCase): mock_get_steps.assert_called_once_with( task, 'clean', interface='deploy', override_priorities={'erase_devices': None, - 'erase_devices_metadata': None, - 'delete_configuration': None, - 'create_configuration': None}) + 'erase_devices_metadata': None}) self.assertEqual(mock_steps, steps) @mock.patch.object(agent_base, 'get_steps', autospec=True) def test_get_clean_steps_config_priority(self, mock_get_steps): # Test that we can override the priority of get clean steps # Use 0 because it is an edge case (false-y) and used in devstack - # for erase_devices, and 42 for RAID cleaning steps as they are - # disabled by default. + # for erase_devices. self.config(erase_devices_priority=0, group='deploy') self.config(erase_devices_metadata_priority=0, group='deploy') - self.config(delete_configuration_priority=42, group='deploy') - self.config(create_configuration_priority=42, group='deploy') mock_steps = [{'priority': 10, 'interface': 'deploy', 'step': 'erase_devices'}] mock_get_steps.return_value = mock_steps @@ -1186,9 +1181,7 @@ class TestAgentDeploy(db_base.DbTestCase): mock_get_steps.assert_called_once_with( task, 'clean', interface='deploy', override_priorities={'erase_devices': 0, - 'erase_devices_metadata': 0, - 'delete_configuration': 42, - 'create_configuration': 42}) + 'erase_devices_metadata': 0}) @mock.patch.object(deploy_utils, 'prepare_inband_cleaning', autospec=True) def test_prepare_cleaning(self, prepare_inband_cleaning_mock): @@ -1763,8 +1756,22 @@ class AgentRAIDTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node.uuid) as task: ret = task.driver.raid.get_clean_steps(task) - self.assertEqual(0, ret[0]['priority']) - self.assertEqual(0, ret[1]['priority']) + self.assertEqual(1, ret[0]['priority']) + self.assertEqual(2, ret[1]['priority']) + + @mock.patch.object(agent_base, 'get_steps', autospec=True) + def test_get_clean_steps_config_priority(self, get_steps_mock): + # Test that we can override the priority of get clean steps + # Use 0 because it is an edge case (false-y) and used in devstack + # for erase_devices. + self.config(create_configuration_priority=50, group='deploy') + self.config(delete_configuration_priority=40, group='deploy') + with task_manager.acquire(self.context, self.node.uuid) as task: + task.driver.raid.get_clean_steps(task) + get_steps_mock.assert_called_once_with( + task, 'clean', interface='raid', + override_priorities={'create_configuration': 50, + 'delete_configuration': 40}) @mock.patch.object(agent_base, 'get_steps', autospec=True) def test_get_deploy_steps(self, get_steps_mock): diff --git a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py index 6ac184b53..289e29e49 100644 --- a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py +++ b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py @@ -980,9 +980,7 @@ class ISCSIDeployTestCase(db_base.DbTestCase): task, 'clean', interface='deploy', override_priorities={ 'erase_devices': 10, - 'erase_devices_metadata': 5, - 'delete_configuration': None, - 'create_configuration': None}) + 'erase_devices_metadata': 5}) self.assertEqual(mock_steps, steps) @mock.patch.object(agent_base, 'execute_step', autospec=True) |