Explicitly set neutron service ports for fullstack

Fullstack neutron-server seems do not accept any connection
during the running period sometimes. This patch explicitly
set listening port range for neutron-server API and ovs agent
openflow.
And make sure other client side connection port does not seize
the server side listening.

Change-Id: If2a7977a3ac795db0bc7f726c0b26c5de638ea47
This commit is contained in:
LIU Yulong 2019-03-17 22:54:59 +08:00
parent 9b897782f8
commit c0132acb52
2 changed files with 31 additions and 2 deletions

View File

@ -228,6 +228,18 @@ def get_free_namespace_port(protocol, namespace=None, start=1024, end=None):
return get_unused_port(used_ports, start, end)
def set_local_port_range(start, end):
utils.execute(
['sysctl', '-w', 'net.ipv4.ip_local_port_range=%d %d' % (start, end)],
run_as_root=True)
utils.execute(['sysctl', '-p'], run_as_root=True)
# verify
port_range = utils.execute(
['sysctl', '-n', 'net.ipv4.ip_local_port_range'], run_as_root=True)
assert int(port_range.split()[0]) == start
assert int(port_range.split()[1]) == end
def create_patch_ports(source, destination):
"""Hook up two OVS bridges.

View File

@ -25,12 +25,22 @@ from neutron.tests import base
from neutron.tests.common import config_fixtures
from neutron.tests.common.exclusive_resources import port
from neutron.tests.common import helpers as c_helpers
from neutron.tests.common import net_helpers
from neutron.tests.fullstack import base as fullstack_base
PHYSICAL_NETWORK_NAME = "physnet1"
MINIMUM_BANDWIDTH_INGRESS_KBPS = 1000
MINIMUM_BANDWIDTH_EGRESS_KBPS = 1000
NEUTRON_SERVER_PORT_START = 10000
NEUTRON_SERVER_PORT_END = 20000
OVS_OF_PORT_LISTEN_START = 20001
OVS_OF_PORT_LISTEN_END = 30000
CLIENT_CONN_PORT_START = 30001
CLIENT_CONN_PORT_END = 65000
class ConfigFixture(config_fixtures.ConfigFileFixture):
"""A fixture that holds an actual Neutron configuration.
@ -101,10 +111,15 @@ class NeutronConfigFixture(ConfigFixture):
self.config['DEFAULT']['router_scheduler_driver'] = (
env_desc.router_scheduler)
net_helpers.set_local_port_range(CLIENT_CONN_PORT_START,
CLIENT_CONN_PORT_END)
def _setUp(self):
self.config['DEFAULT'].update({
'bind_port': self.useFixture(
port.ExclusivePort(constants.PROTO_NAME_TCP)).port
port.ExclusivePort(constants.PROTO_NAME_TCP,
start=NEUTRON_SERVER_PORT_START,
end=NEUTRON_SERVER_PORT_END)).port
})
super(NeutronConfigFixture, self)._setUp()
@ -213,7 +228,9 @@ class OVSConfigFixture(ConfigFixture):
if self.config['ovs']['of_interface'] == 'native':
self.config['ovs'].update({
'of_listen_port': self.useFixture(
port.ExclusivePort(constants.PROTO_NAME_TCP)).port
port.ExclusivePort(constants.PROTO_NAME_TCP,
start=OVS_OF_PORT_LISTEN_START,
end=OVS_OF_PORT_LISTEN_END)).port
})
super(OVSConfigFixture, self)._setUp()