ensure that socat serial proxy keeps running

Socat as configured would exit on client disconnect. Since there was
no active process monitoring, the process would (a) become a zombie,
and (b) would not restart, which would disable console access.

This commits adds the fork,max-children=1 parametesr to the socat
call, which makes socat persistent until it is explicitly killed.

Change-Id: I612cd9bca403b7a77ad3e671c1fdadd55353d5f7
Story: 2005024
Task:  29503
This commit is contained in:
Lars Kellogg-Stedman 2019-02-15 11:35:54 -05:00 committed by Julia Kreger
parent 8978237388
commit f369fdd334
3 changed files with 17 additions and 4 deletions

View File

@ -305,9 +305,11 @@ def start_socat_console(node_uuid, port, console_cmd):
console_host = CONF.console.socat_address
if netutils.is_valid_ipv6(console_host):
arg = 'TCP6-LISTEN:%(port)s,bind=[%(host)s],reuseaddr'
arg = ('TCP6-LISTEN:%(port)s,bind=[%(host)s],reuseaddr,fork,'
'max-children=1')
else:
arg = 'TCP4-LISTEN:%(port)s,bind=%(host)s,reuseaddr'
arg = ('TCP4-LISTEN:%(port)s,bind=%(host)s,reuseaddr,fork,'
'max-children=1')
args.append(arg % {'host': console_host,
'port': port})

View File

@ -467,13 +467,15 @@ class ConsoleUtilsTestCase(db_base.DbTestCase):
def test_start_socat_console_check_arg_bind_addr_default_ipv4(self):
self.config(my_ip='10.0.0.1')
args = self._test_start_socat_console_check_arg()
self.assertIn('TCP4-LISTEN:%s,bind=10.0.0.1,reuseaddr' %
self.assertIn('TCP4-LISTEN:%s,bind=10.0.0.1,reuseaddr,fork,'
'max-children=1' %
self.info['port'], args)
def test_start_socat_console_check_arg_bind_addr_ipv4(self):
self.config(socat_address='10.0.0.1', group='console')
args = self._test_start_socat_console_check_arg()
self.assertIn('TCP4-LISTEN:%s,bind=10.0.0.1,reuseaddr' %
self.assertIn('TCP4-LISTEN:%s,bind=10.0.0.1,reuseaddr,fork,'
'max-children=1' %
self.info['port'], args)
@mock.patch.object(os.path, 'exists', autospec=True)

View File

@ -0,0 +1,9 @@
---
fixes:
- Ironic does not monitor the socat proxy started for serial console
access. The socat process would exit on client disconnect, which
would (a) leave a zombie socat process in the process table and (b)
disable any subsequent serial console connections. Fixed the issue by
updating Ironic to call socat with the ``fork,max-children=1`` options,
which makes socat persist and accept multiple connections (but only one
at a time). See https://storyboard.openstack.org/#!/story/2005024.