diff options
author | Kaifeng Wang <kaifeng.w@gmail.com> | 2022-12-25 12:14:06 +0800 |
---|---|---|
committer | Julia Kreger <juliaashleykreger@gmail.com> | 2023-02-15 17:42:37 +0000 |
commit | c9c9b3100d3bd8983ca53a75c4a4e5f9c7f122b9 (patch) | |
tree | 700aac2f5e5e9d37cb3b4c03e21662480c9eea4c /ironic/tests | |
parent | ef772c2c1e84769a982c54ec8832e2a06b8f1911 (diff) | |
download | ironic-c9c9b3100d3bd8983ca53a75c4a4e5f9c7f122b9.tar.gz |
Fixes console port conflict occurs in certain path
The dynamically allocated console port for a node is saved
into database and reused on subsequent console operations.
In certain code path the port record cann't be trusted and
we should do a re-allocation.
This patch fixes the issue by ignores previous allocation
record. The extra cleanup in the takeover is not required
anymore and removed as well.
Change-Id: I1a07ea9b30a2c760af7a6a4e39f3ff227df28fff
Story: 2010489
Task: 47061
Diffstat (limited to 'ironic/tests')
-rw-r--r-- | ironic/tests/unit/conductor/test_manager.py | 38 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_ipmitool.py | 10 |
2 files changed, 10 insertions, 38 deletions
diff --git a/ironic/tests/unit/conductor/test_manager.py b/ironic/tests/unit/conductor/test_manager.py index fd206e36d..b4a18c8c2 100644 --- a/ironic/tests/unit/conductor/test_manager.py +++ b/ironic/tests/unit/conductor/test_manager.py @@ -7244,44 +7244,6 @@ class DoNodeTakeOverTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase): mock.call(task, 'console_restore', obj_fields.NotificationStatus.ERROR)]) - @mock.patch.object(notification_utils, 'emit_console_notification', - autospec=True) - @mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console', - autospec=True) - @mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over', - autospec=True) - @mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare', - autospec=True) - def test__do_takeover_with_console_port_cleaned(self, mock_prepare, - mock_take_over, - mock_start_console, - mock_notify): - self._start_service(start_consoles=False) - node = obj_utils.create_test_node(self.context, driver='fake-hardware', - console_enabled=True) - di_info = node.driver_internal_info - di_info['allocated_ipmi_terminal_port'] = 12345 - node.driver_internal_info = di_info - node.save() - - task = task_manager.TaskManager(self.context, node.uuid) - - self.service._do_takeover(task) - node.refresh() - self.assertIsNone(node.last_error) - self.assertTrue(node.console_enabled) - self.assertIsNone( - node.driver_internal_info.get('allocated_ipmi_terminal_port', - None)) - mock_prepare.assert_called_once_with(task.driver.deploy, task) - mock_take_over.assert_called_once_with(task.driver.deploy, task) - mock_start_console.assert_called_once_with(task.driver.console, task) - mock_notify.assert_has_calls( - [mock.call(task, 'console_restore', - obj_fields.NotificationStatus.START), - mock.call(task, 'console_restore', - obj_fields.NotificationStatus.END)]) - @mgr_utils.mock_record_keepalive class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase): diff --git a/ironic/tests/unit/drivers/modules/test_ipmitool.py b/ironic/tests/unit/drivers/modules/test_ipmitool.py index b982e0cb2..016b9d6ed 100644 --- a/ironic/tests/unit/drivers/modules/test_ipmitool.py +++ b/ironic/tests/unit/drivers/modules/test_ipmitool.py @@ -3255,6 +3255,11 @@ class IPMIToolShellinaboxTestCase(db_base.DbTestCase): mock_start.return_value = None mock_info.return_value = {'port': None} mock_alloc.return_value = 1234 + # Ensure allocated port is not re-used + dii = self.node.driver_internal_info + dii['allocated_ipmi_terminal_port'] = 4321 + self.node.driver_internal_info = dii + self.node.save() with task_manager.acquire(self.context, self.node.uuid) as task: @@ -3468,6 +3473,11 @@ class IPMIToolSocatDriverTestCase(IPMIToolShellinaboxTestCase): mock_start.return_value = None mock_info.return_value = {'port': None} mock_alloc.return_value = 1234 + # Ensure allocated port is not re-used + dii = self.node.driver_internal_info + dii['allocated_ipmi_terminal_port'] = 4321 + self.node.driver_internal_info = dii + self.node.save() with task_manager.acquire(self.context, self.node.uuid) as task: |