diff --git a/etc/ironic/ironic.conf.sample b/etc/ironic/ironic.conf.sample index 788e45b78f..de235510d0 100644 --- a/etc/ironic/ironic.conf.sample +++ b/etc/ironic/ironic.conf.sample @@ -850,6 +850,13 @@ # Erased. Defaults to True. (boolean value) #shred_final_overwrite_with_zeros = true +# Defines what to do if an ATA secure erase operation fails +# during cleaning in the Ironic Python Agent. If False, the +# cleaning operation will fail and the node will be put in +# ``clean failed`` state. If True, shred will be invoked and +# cleaning will continue. (boolean value) +#continue_if_disk_secure_erase_fails = false + # Whether to power off a node after deploy failure. Defaults # to True. (boolean value) #power_off_after_deploy_failure = true diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 50ba3fbc7c..14e2c66424 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -77,6 +77,14 @@ deploy_opts = [ "deploy.shred_random_overwrite_interations is 0. This " "option is only used if a device could not be ATA " "Secure Erased. Defaults to True.")), + cfg.BoolOpt('continue_if_disk_secure_erase_fails', + default=False, + help=_('Defines what to do if an ATA secure erase operation ' + 'fails during cleaning in the Ironic Python Agent. ' + 'If False, the cleaning operation will fail and the ' + 'node will be put in ``clean failed`` state. ' + 'If True, shred will be invoked and cleaning will ' + 'continue.')), cfg.BoolOpt('power_off_after_deploy_failure', default=True, help=_('Whether to power off a node after deploy failure. ' @@ -659,6 +667,8 @@ def agent_add_clean_params(task): info['agent_erase_devices_iterations'] = random_iterations zeroize = CONF.deploy.shred_final_overwrite_with_zeros info['agent_erase_devices_zeroize'] = zeroize + erase_fallback = CONF.deploy.continue_if_disk_secure_erase_fails + info['agent_continue_if_ata_erase_failed'] = erase_fallback task.node.driver_internal_info = info task.node.save() diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py index 372479a4df..c654f1392c 100644 --- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py +++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py @@ -1715,6 +1715,8 @@ class AgentMethodsTestCase(db_base.DbTestCase): cfg.CONF.set_override('shred_random_overwrite_iterations', 2, 'deploy') cfg.CONF.set_override('shred_final_overwrite_with_zeros', False, 'deploy') + cfg.CONF.set_override('continue_if_disk_secure_erase_fails', True, + 'deploy') with task_manager.acquire( self.context, self.node.uuid, shared=False) as task: utils.agent_add_clean_params(task) @@ -1722,6 +1724,8 @@ class AgentMethodsTestCase(db_base.DbTestCase): 'agent_erase_devices_iterations')) self.assertEqual(False, task.node.driver_internal_info.get( 'agent_erase_devices_zeroize')) + self.assertEqual(True, task.node.driver_internal_info.get( + 'agent_continue_if_ata_erase_failed')) @mock.patch('ironic.dhcp.neutron.NeutronDHCPApi.delete_cleaning_ports', autospec=True) diff --git a/releasenotes/notes/add-agent-erase-fallback-b07613a7042fe236.yaml b/releasenotes/notes/add-agent-erase-fallback-b07613a7042fe236.yaml new file mode 100644 index 0000000000..3471b16f9b --- /dev/null +++ b/releasenotes/notes/add-agent-erase-fallback-b07613a7042fe236.yaml @@ -0,0 +1,16 @@ +--- +features: + - A new configuration option + ``[deploy]continue_if_disk_secure_erase_fails``, which + has a default value of False, has been added. If set to + True, the Ironic Python Agent will revert to a disk shred + operation if an ATA secure erase operation fails. Under + normal circumstances, the failure of an ATA secure erase + operation results in the node being put in ``clean failed`` + state. +upgrades: + - A new configuration option + ``[deploy]continue_if_disk_secure_erase_fails``, which + has a default value of False, has been added. The default + setting represents the standard behavior of the Ironic + Python Agent during a cleaning failure.