From 1ee9111263db38d77b76ca160cb2096156c0b08d Mon Sep 17 00:00:00 2001 From: Yuriy Zveryanskyy Date: Mon, 20 Mar 2017 11:21:29 +0200 Subject: [PATCH] Remove unneeded exception handling from agent driver RPC "continue_node_clean" is an RPC cast, there will be no exception raised by the conductor. Change-Id: I4d23dc4a7bfb5d3835e62ac580dbb7ce77a11d3c --- ironic/drivers/modules/agent_base_vendor.py | 32 ++++++++----------- .../drivers/modules/test_agent_base_vendor.py | 23 ------------- 2 files changed, 14 insertions(+), 41 deletions(-) diff --git a/ironic/drivers/modules/agent_base_vendor.py b/ironic/drivers/modules/agent_base_vendor.py index 13cc94b8b4..aa4e444a92 100644 --- a/ironic/drivers/modules/agent_base_vendor.py +++ b/ironic/drivers/modules/agent_base_vendor.py @@ -302,24 +302,20 @@ class HeartbeatMixin(object): node.touch_provisioning() elif node.provision_state == states.CLEANWAIT: node.touch_provisioning() - try: - if not node.clean_step: - LOG.debug('Node %s just booted to start cleaning.', - node.uuid) - msg = _('Node failed to start the first cleaning ' - 'step.') - # First, cache the clean steps - self.refresh_clean_steps(task) - # Then set/verify node clean steps and start cleaning - manager_utils.set_node_cleaning_steps(task) - _notify_conductor_resume_clean(task) - else: - msg = _('Node failed to check cleaning progress.') - self.continue_cleaning(task) - except exception.NoFreeConductorWorker: - # waiting for the next heartbeat, node.last_error and - # logging message is filled already via conductor's hook - pass + if not node.clean_step: + LOG.debug('Node %s just booted to start cleaning.', + node.uuid) + msg = _('Node failed to start the first cleaning step.') + # First, cache the clean steps + self.refresh_clean_steps(task) + # Then set/verify node clean steps and start cleaning + manager_utils.set_node_cleaning_steps(task) + # The exceptions from RPC are not possible as we using cast + # here + _notify_conductor_resume_clean(task) + else: + msg = _('Node failed to check cleaning progress.') + self.continue_cleaning(task) except Exception as e: err_info = {'node': node.uuid, 'msg': msg, 'e': e} diff --git a/ironic/tests/unit/drivers/modules/test_agent_base_vendor.py b/ironic/tests/unit/drivers/modules/test_agent_base_vendor.py index 183814abd9..61cde7bc46 100644 --- a/ironic/tests/unit/drivers/modules/test_agent_base_vendor.py +++ b/ironic/tests/unit/drivers/modules/test_agent_base_vendor.py @@ -215,29 +215,6 @@ class HeartbeatMixinTest(AgentDeployMixinBaseTest): mock_continue.assert_called_once_with(mock.ANY, task) mock_handler.assert_called_once_with(task, mock.ANY) - @mock.patch.object(manager_utils, 'cleaning_error_handler') - @mock.patch.object(agent_base_vendor.HeartbeatMixin, - 'continue_cleaning', autospec=True) - def test_heartbeat_continue_cleaning_no_worker(self, mock_continue, - mock_handler): - self.node.clean_step = { - 'priority': 10, - 'interface': 'deploy', - 'step': 'foo', - 'reboot_requested': False - } - - mock_continue.side_effect = exception.NoFreeConductorWorker() - - self.node.provision_state = states.CLEANWAIT - self.node.save() - with task_manager.acquire( - self.context, self.node.uuid, shared=False) as task: - self.deploy.heartbeat(task, 'http://127.0.0.1:8080') - - mock_continue.assert_called_once_with(mock.ANY, task) - self.assertFalse(mock_handler.called) - @mock.patch.object(agent_base_vendor.HeartbeatMixin, 'continue_deploy', autospec=True) @mock.patch.object(agent_base_vendor.HeartbeatMixin,