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
This commit is contained in:
Mohammed Naser 2021-03-02 02:42:16 -05:00
parent f5d9cabef2
commit 6ba1ecad17
5 changed files with 35 additions and 3 deletions

View File

@ -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,

View File

@ -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',

View File

@ -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):

View File

@ -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)

View File

@ -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.