summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-25 20:02:42 +0000
committerGerrit Code Review <review@openstack.org>2016-08-25 20:02:42 +0000
commit120a643a374b5bb741f2273d33f55d70bd7ec3fa (patch)
treeb1bf30eec106382271d3eb01ecf7dda2a596ba82
parent2f158abf2ecc5a734d155cb425ae29841ddfa088 (diff)
parent2e1fcc08d0100a4ff10900704e2282ee83920d29 (diff)
downloadneutron-120a643a374b5bb741f2273d33f55d70bd7ec3fa.tar.gz
Merge "Handle deleted ports when creating a list of fdb entries" into stable/liberty
-rw-r--r--neutron/plugins/ml2/drivers/l2pop/mech_driver.py4
-rw-r--r--neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py35
2 files changed, 35 insertions, 4 deletions
diff --git a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py
index 4e3c78456f..b268e5be50 100644
--- a/neutron/plugins/ml2/drivers/l2pop/mech_driver.py
+++ b/neutron/plugins/ml2/drivers/l2pop/mech_driver.py
@@ -41,6 +41,10 @@ class L2populationMechanismDriver(api.MechanismDriver,
self.rpc_ctx = n_context.get_admin_context_without_session()
def _get_port_fdb_entries(self, port):
+ # the port might be concurrently deleted
+ if not port or not port.get('fixed_ips'):
+ return []
+
return [l2pop_rpc.PortInfo(mac_address=port['mac_address'],
ip_address=ip['ip_address'])
for ip in port['fixed_ips']]
diff --git a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py
index 9c3e96d149..7ca3aad3eb 100644
--- a/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py
+++ b/neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py
@@ -843,7 +843,7 @@ class TestL2PopulationMechDriver(base.BaseTestCase):
def _test_create_agent_fdb(self, fdb_network_ports, agent_ips):
mech_driver = l2pop_mech_driver.L2populationMechanismDriver()
tunnel_network_ports, tunnel_agent = (
- self._mock_network_ports(HOST + '1', None))
+ self._mock_network_ports(HOST + '1', [None]))
agent_ips[tunnel_agent] = '10.0.0.1'
def agent_ip_side_effect(agent):
@@ -867,17 +867,17 @@ class TestL2PopulationMechDriver(base.BaseTestCase):
segment,
'network_id')
- def _mock_network_ports(self, host_name, binding):
+ def _mock_network_ports(self, host_name, bindings):
agent = mock.Mock()
agent.host = host_name
- return [(binding, agent)], agent
+ return [(binding, agent) for binding in bindings], agent
def test_create_agent_fdb(self):
binding = mock.Mock()
binding.port = {'mac_address': '00:00:DE:AD:BE:EF',
'fixed_ips': [{'ip_address': '1.1.1.1'}]}
fdb_network_ports, fdb_agent = (
- self._mock_network_ports(HOST + '2', binding))
+ self._mock_network_ports(HOST + '2', [binding]))
agent_ips = {fdb_agent: '20.0.0.1'}
agent_fdb = self._test_create_agent_fdb(fdb_network_ports,
@@ -907,6 +907,33 @@ class TestL2PopulationMechDriver(base.BaseTestCase):
[constants.FLOODING_ENTRY]}}
self.assertEqual(expected_result, result)
+ def test_create_agent_fdb_concurrent_port_deletion(self):
+ binding = mock.Mock()
+ binding.port = {'mac_address': '00:00:DE:AD:BE:EF',
+ 'fixed_ips': [{'ip_address': '1.1.1.1'}]}
+ binding2 = mock.Mock()
+ # the port was deleted
+ binding2.port = None
+ fdb_network_ports, fdb_agent = (
+ self._mock_network_ports(HOST + '2', [binding, binding2]))
+ agent_ips = {fdb_agent: '20.0.0.1'}
+
+ agent_fdb = self._test_create_agent_fdb(fdb_network_ports,
+ agent_ips)
+ result = agent_fdb['network_id']
+
+ expected_result = {'segment_id': 1,
+ 'network_type': 'vxlan',
+ 'ports':
+ {'10.0.0.1':
+ [constants.FLOODING_ENTRY],
+ '20.0.0.1':
+ [constants.FLOODING_ENTRY,
+ l2pop_rpc.PortInfo(
+ mac_address='00:00:DE:AD:BE:EF',
+ ip_address='1.1.1.1')]}}
+ self.assertEqual(expected_result, result)
+
def test_update_port_precommit_mac_address_changed_raises(self):
port = {'status': u'ACTIVE',
'device_owner': u'compute:None',