From bc87926e60bca11a1bc91dfaadb8e571a38c0e5f Mon Sep 17 00:00:00 2001 From: Maurice Escher Date: Thu, 28 Mar 2019 11:22:02 +0100 Subject: [PATCH] NeutronBindNetworkPlugin: fix multi segment mtu Neutron mtu value for network allocation is taken from share network, so the share network needs to be updated with the mtu before the allocation is created. This prevents the mtu being empty on the first network allocation in a share network. Change-Id: I89de02af7d739bbe70f1d893cc2b6ced0157d120 Closes-Bug: #1822099 --- .../network/neutron/neutron_network_plugin.py | 23 +++++++++++++++++-- .../network/neutron/test_neutron_plugin.py | 4 ++-- ...ultisegment-mtu.yaml-ac2e31c084d8bbb6.yaml | 5 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/bug-1822099-fix-multisegment-mtu.yaml-ac2e31c084d8bbb6.yaml diff --git a/manila/network/neutron/neutron_network_plugin.py b/manila/network/neutron/neutron_network_plugin.py index 13efb1fced..e356f42b26 100644 --- a/manila/network/neutron/neutron_network_plugin.py +++ b/manila/network/neutron/neutron_network_plugin.py @@ -566,18 +566,37 @@ class NeutronBindNetworkPlugin(NeutronNetworkPlugin): In case of dynamic multi segments the segment is determined while binding the port. Therefore this method will return for multi segments - network without storing network information. + network without storing network information (apart from mtu). Instead, multi segments network will wait until ports are bound and then store network information (see allocate_network()). """ if self._is_neutron_multi_segment(share_network): # In case of dynamic multi segment the segment is determined while - # binding the port + # binding the port, only mtu is known and already needed + self._save_neutron_network_mtu(context, share_network) return super(NeutronBindNetworkPlugin, self)._save_neutron_network_data( context, share_network) + def _save_neutron_network_mtu(self, context, share_network): + """Store the Neutron network mtu. + + In case of dynamic multi segments only the mtu needs storing before + binding the port. + """ + net_info = self.neutron_api.get_network( + share_network['neutron_net_id']) + + mtu_dict = { + 'mtu': net_info['mtu'], + } + share_network.update(mtu_dict) + + if self.label != 'admin': + self.db.share_network_update( + context, share_network['id'], mtu_dict) + def allocate_network(self, context, share_server, share_network=None, **kwargs): ports = super(NeutronBindNetworkPlugin, self).allocate_network( diff --git a/manila/tests/network/neutron/test_neutron_plugin.py b/manila/tests/network/neutron/test_neutron_plugin.py index 4e20431d99..809cfcda7f 100644 --- a/manila/tests/network/neutron/test_neutron_plugin.py +++ b/manila/tests/network/neutron/test_neutron_plugin.py @@ -166,7 +166,7 @@ fake_share_network_multi = { 'ip_version': None, 'cidr': 'fake_cidr', 'gateway': 'fake_gateway', - 'mtu': fake_neutron_network_multi['mtu'], + 'mtu': fake_neutron_network_multi['mtu'] - 1, } fake_network_allocation_multi = { @@ -181,7 +181,7 @@ fake_network_allocation_multi = { 'ip_version': fake_neutron_subnet['ip_version'], 'cidr': fake_neutron_subnet['cidr'], 'gateway': fake_neutron_subnet['gateway_ip'], - 'mtu': fake_share_network_multi['mtu'], + 'mtu': fake_neutron_network_multi['mtu'], } fake_binding_profile = { diff --git a/releasenotes/notes/bug-1822099-fix-multisegment-mtu.yaml-ac2e31c084d8bbb6.yaml b/releasenotes/notes/bug-1822099-fix-multisegment-mtu.yaml-ac2e31c084d8bbb6.yaml new file mode 100644 index 0000000000..4dbc7e349a --- /dev/null +++ b/releasenotes/notes/bug-1822099-fix-multisegment-mtu.yaml-ac2e31c084d8bbb6.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Update share networks with MTU before creating network allocations so that + the first allocation in a share network is correct.