Fix Reopen Web Console Duplicate Sol Session
Reopen web console may occasionally result in duplicated sol session. get_console action open one console process while another sol session remains. This patch adds "sol deactivate" action before get console. Make sure the current connection always a success. Change-Id: Ie5d9c94a3e9e3561b6aa1a52462d6739662d4eb0
This commit is contained in:
parent
ff4e836c55
commit
e5f7e052ac
@ -1624,6 +1624,14 @@ class IPMIShellinaboxConsole(IPMIConsole):
|
||||
def get_console(self, task):
|
||||
"""Get the type and connection information about the console."""
|
||||
driver_info = _parse_driver_info(task.node)
|
||||
|
||||
try:
|
||||
self._exec_stop_console(driver_info)
|
||||
except OSError:
|
||||
# We need to drop any existing sol sessions with sol deactivate.
|
||||
# OSError is raised when sol session is already deactivated,
|
||||
# so we can ignore it.
|
||||
pass
|
||||
url = console_utils.get_shellinabox_console_url(driver_info['port'])
|
||||
return {'type': 'shellinabox', 'url': url}
|
||||
|
||||
@ -1687,5 +1695,13 @@ class IPMISocatConsole(IPMIConsole):
|
||||
:param task: a task from TaskManager
|
||||
"""
|
||||
driver_info = _parse_driver_info(task.node)
|
||||
|
||||
try:
|
||||
self._exec_stop_console(driver_info)
|
||||
except OSError:
|
||||
# We need to drop any existing sol sessions with sol deactivate.
|
||||
# OSError is raised when sol session is already deactivated,
|
||||
# so we can ignore it.
|
||||
pass
|
||||
url = console_utils.get_socat_console_url(driver_info['port'])
|
||||
return {'type': 'socat', 'url': url}
|
||||
|
@ -3418,7 +3418,9 @@ class IPMIToolShellinaboxTestCase(db_base.DbTestCase):
|
||||
|
||||
@mock.patch.object(console_utils, 'get_shellinabox_console_url',
|
||||
autospec=True)
|
||||
def test_get_console(self, mock_get):
|
||||
@mock.patch.object(ipmi.IPMIShellinaboxConsole, "_exec_stop_console",
|
||||
autospec=True)
|
||||
def test_get_console(self, mock_exec_stop, mock_get):
|
||||
url = 'http://localhost:4201'
|
||||
mock_get.return_value = url
|
||||
expected = {'type': 'shellinabox', 'url': url}
|
||||
@ -3426,7 +3428,9 @@ class IPMIToolShellinaboxTestCase(db_base.DbTestCase):
|
||||
with task_manager.acquire(self.context,
|
||||
self.node.uuid) as task:
|
||||
console_info = self.console.get_console(task)
|
||||
driver_info = ipmi._parse_driver_info(task.node)
|
||||
|
||||
mock_exec_stop.assert_called_once_with(self.console, driver_info)
|
||||
self.assertEqual(expected, console_info)
|
||||
mock_get.assert_called_once_with(self.info['port'])
|
||||
|
||||
@ -3651,7 +3655,9 @@ class IPMIToolSocatDriverTestCase(IPMIToolShellinaboxTestCase):
|
||||
|
||||
@mock.patch.object(console_utils, 'get_socat_console_url',
|
||||
autospec=True)
|
||||
def test_get_console(self, mock_get_url):
|
||||
@mock.patch.object(ipmi.IPMISocatConsole, '_exec_stop_console',
|
||||
autospec=True)
|
||||
def test_get_console(self, mock_exec_stop, mock_get_url):
|
||||
url = 'tcp://localhost:4201'
|
||||
mock_get_url.return_value = url
|
||||
expected = {'type': 'socat', 'url': url}
|
||||
@ -3659,6 +3665,8 @@ class IPMIToolSocatDriverTestCase(IPMIToolShellinaboxTestCase):
|
||||
with task_manager.acquire(self.context,
|
||||
self.node.uuid) as task:
|
||||
console_info = self.console.get_console(task)
|
||||
driver_info = ipmi._parse_driver_info(task.node)
|
||||
|
||||
mock_exec_stop.assert_called_once_with(self.console, driver_info)
|
||||
self.assertEqual(expected, console_info)
|
||||
mock_get_url.assert_called_once_with(self.info['port'])
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Ironic now stops any active IPMI Serial-Over-LAN console sessions when
|
||||
initializing a console session. This resolves and issue where console support
|
||||
would fail if a previous console session was not properly disconnected.
|
Loading…
Reference in New Issue
Block a user