diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py index 1160066971..bf6d02d8ca 100644 --- a/ironic/drivers/modules/agent.py +++ b/ironic/drivers/modules/agent.py @@ -459,6 +459,7 @@ class AgentDeploy(AgentDeployMixin, base.DeployInterface): """ if CONF.agent.manage_agent_boot: task.driver.boot.clean_up_ramdisk(task) + task.driver.boot.clean_up_instance(task) provider = dhcp_factory.DHCPFactory() provider.clean_dhcp(task) diff --git a/ironic/tests/unit/drivers/modules/test_agent.py b/ironic/tests/unit/drivers/modules/test_agent.py index b011ac9e91..fa640acd78 100644 --- a/ironic/tests/unit/drivers/modules/test_agent.py +++ b/ironic/tests/unit/drivers/modules/test_agent.py @@ -374,20 +374,25 @@ class TestAgentDeploy(db_base.DbTestCase): @mock.patch('ironic.common.dhcp_factory.DHCPFactory._set_dhcp_provider') @mock.patch('ironic.common.dhcp_factory.DHCPFactory.clean_dhcp') + @mock.patch.object(pxe.PXEBoot, 'clean_up_instance') @mock.patch.object(pxe.PXEBoot, 'clean_up_ramdisk') - def test_clean_up(self, pxe_clean_up_ramdisk_mock, clean_dhcp_mock, + def test_clean_up(self, pxe_clean_up_ramdisk_mock, + pxe_clean_up_instance_mock, clean_dhcp_mock, set_dhcp_provider_mock): with task_manager.acquire( self.context, self.node['uuid'], shared=False) as task: self.driver.clean_up(task) pxe_clean_up_ramdisk_mock.assert_called_once_with(task) + pxe_clean_up_instance_mock.assert_called_once_with(task) set_dhcp_provider_mock.assert_called_once_with() clean_dhcp_mock.assert_called_once_with(task) @mock.patch('ironic.common.dhcp_factory.DHCPFactory._set_dhcp_provider') @mock.patch('ironic.common.dhcp_factory.DHCPFactory.clean_dhcp') + @mock.patch.object(pxe.PXEBoot, 'clean_up_instance') @mock.patch.object(pxe.PXEBoot, 'clean_up_ramdisk') def test_clean_up_manage_agent_boot_false(self, pxe_clean_up_ramdisk_mock, + pxe_clean_up_instance_mock, clean_dhcp_mock, set_dhcp_provider_mock): with task_manager.acquire( @@ -395,6 +400,7 @@ class TestAgentDeploy(db_base.DbTestCase): self.config(group='agent', manage_agent_boot=False) self.driver.clean_up(task) self.assertFalse(pxe_clean_up_ramdisk_mock.called) + pxe_clean_up_instance_mock.assert_called_once_with(task) set_dhcp_provider_mock.assert_called_once_with() clean_dhcp_mock.assert_called_once_with(task) diff --git a/releasenotes/notes/fix-agent-clean-up-9a25deb85bc53d9b.yaml b/releasenotes/notes/fix-agent-clean-up-9a25deb85bc53d9b.yaml new file mode 100644 index 0000000000..69e3ae12ab --- /dev/null +++ b/releasenotes/notes/fix-agent-clean-up-9a25deb85bc53d9b.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes an issue wherein agent based deploy do not call + clean up the instance related configurations done on + the Ironic node.