From 6ba1ecad17bea362f4f9ea8f1641e9d6d87bcfb8 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Tue, 2 Mar 2021 02:42:16 -0500 Subject: [PATCH] Allow users to configure priority for {create,delete}_configuration At the moment, users do not have a way to easily prioritize those cleaning steps into automatic cleaning. This patch allows the user to enable those options and prioritize them as needed for automatic cleaning. Change-Id: I3b647e39982c0a98abac7b0a7c1c60215d6db4f2 --- ironic/conf/deploy.py | 16 ++++++++++++++++ ironic/drivers/modules/agent_base.py | 2 ++ ironic/tests/unit/drivers/modules/test_agent.py | 12 ++++++++++-- .../unit/drivers/modules/test_iscsi_deploy.py | 4 +++- ...dd-clean-steps-priority-88d7de5973500a7d.yaml | 4 ++++ 5 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add-clean-steps-priority-88d7de5973500a7d.yaml diff --git a/ironic/conf/deploy.py b/ironic/conf/deploy.py index adc6f52a7f..49975595cd 100644 --- a/ironic/conf/deploy.py +++ b/ironic/conf/deploy.py @@ -55,6 +55,22 @@ opts = [ 'ramdisk (defaults to 99 for the ' 'GenericHardwareManager). If set to 0, will not run ' 'during cleaning.')), + cfg.IntOpt('delete_configuration_priority', + mutable=True, + help=_('Priority to run in-band clean step that erases ' + 'RAID configuration from devices, via the Ironic ' + 'Python Agent ramdisk. If unset, will use the ' + 'priority set in the ramdisk (defaults to 0 for the ' + 'GenericHardwareManager). If set to 0, will not run ' + 'during cleaning.')), + cfg.IntOpt('create_configuration_priority', + mutable=True, + help=_('Priority to run in-band clean step that creates ' + 'RAID configuration from devices, via the Ironic ' + 'Python Agent ramdisk. If unset, will use the ' + 'priority set in the ramdisk (defaults to 0 for the ' + 'GenericHardwareManager). If set to 0, will not run ' + 'during cleaning.')), cfg.IntOpt('shred_random_overwrite_iterations', default=1, min=0, diff --git a/ironic/drivers/modules/agent_base.py b/ironic/drivers/modules/agent_base.py index 35ad016f74..da90bb5031 100644 --- a/ironic/drivers/modules/agent_base.py +++ b/ironic/drivers/modules/agent_base.py @@ -852,6 +852,8 @@ 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 56c971101f..8b50b33e4a 100644 --- a/ironic/tests/unit/drivers/modules/test_agent.py +++ b/ironic/tests/unit/drivers/modules/test_agent.py @@ -1163,15 +1163,21 @@ 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}) + 'erase_devices_metadata': None, + 'delete_configuration': None, + 'create_configuration': 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. 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 @@ -1180,7 +1186,9 @@ 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}) + 'erase_devices_metadata': 0, + 'delete_configuration': 42, + 'create_configuration': 42}) @mock.patch.object(deploy_utils, 'prepare_inband_cleaning', autospec=True) def test_prepare_cleaning(self, prepare_inband_cleaning_mock): diff --git a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py index fc763f8b05..90e9a6eade 100644 --- a/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py +++ b/ironic/tests/unit/drivers/modules/test_iscsi_deploy.py @@ -980,7 +980,9 @@ class ISCSIDeployTestCase(db_base.DbTestCase): task, 'clean', interface='deploy', override_priorities={ 'erase_devices': 10, - 'erase_devices_metadata': 5}) + 'erase_devices_metadata': 5, + 'delete_configuration': None, + 'create_configuration': None}) self.assertEqual(mock_steps, steps) @mock.patch.object(agent_base, 'execute_step', autospec=True) diff --git a/releasenotes/notes/add-clean-steps-priority-88d7de5973500a7d.yaml b/releasenotes/notes/add-clean-steps-priority-88d7de5973500a7d.yaml new file mode 100644 index 0000000000..8a01a7d711 --- /dev/null +++ b/releasenotes/notes/add-clean-steps-priority-88d7de5973500a7d.yaml @@ -0,0 +1,4 @@ +--- +features: + - It is now possible to configure a priority for both the delete and create + configuration RAID cleaning steps which are disabled by default. \ No newline at end of file