From ef9300cb5995348ed70afcd0a626f81371dd4b75 Mon Sep 17 00:00:00 2001 From: Shivanand Tendulker Date: Mon, 27 Mar 2017 06:15:02 -0400 Subject: [PATCH] Call clean_up_instance() during node teardown for Agent deploy Agent based deploy do not call boot.clean_up_instance() during node teardown. This is required so that instance clean up can happen as part of node teardown. Change-Id: I6077b69f17ce462b6aae1b16fdb40158cf111c5e Closes-Bug: #1676321 --- ironic/drivers/modules/agent.py | 1 + ironic/tests/unit/drivers/modules/test_agent.py | 8 +++++++- .../notes/fix-agent-clean-up-9a25deb85bc53d9b.yaml | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-agent-clean-up-9a25deb85bc53d9b.yaml 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.