Merge "Check for unbound ports in L3 RPC handler" into stable/newton

This commit is contained in:
Jenkins 2017-01-20 02:05:15 +00:00 committed by Gerrit Code Review
commit 91cc0e2fd5
2 changed files with 12 additions and 3 deletions

View File

@ -136,12 +136,13 @@ class L3RpcCallback(object):
def _ensure_host_set_on_port(self, context, host, port, router_id=None,
ha_router_port=False):
not_bound = port and port.get(portbindings.VIF_TYPE) in (
portbindings.VIF_TYPE_BINDING_FAILED,
portbindings.VIF_TYPE_UNBOUND)
if (port and host is not None and
(port.get('device_owner') !=
constants.DEVICE_OWNER_DVR_INTERFACE and
port.get(portbindings.HOST_ID) != host or
port.get(portbindings.VIF_TYPE) ==
portbindings.VIF_TYPE_BINDING_FAILED)):
port.get(portbindings.HOST_ID) != host or not_bound)):
# Ports owned by non-HA routers are bound again if they're
# already bound but the router moved to another host.

View File

@ -3616,6 +3616,14 @@ class L3RpcCallbackTestCase(base.BaseTestCase):
self.l3_rpc_cb._ensure_host_set_on_port(None, None, port)
self.assertFalse(self.l3_rpc_cb.plugin.update_port.called)
def test__ensure_host_set_on_port_bad_bindings(self):
for b in (portbindings.VIF_TYPE_BINDING_FAILED,
portbindings.VIF_TYPE_UNBOUND):
port = {'id': 'id', portbindings.HOST_ID: 'somehost',
portbindings.VIF_TYPE: b}
self.l3_rpc_cb._ensure_host_set_on_port(None, 'somehost', port)
self.assertTrue(self.l3_rpc_cb.plugin.update_port.called)
def test__ensure_host_set_on_port_update_on_concurrent_delete(self):
port_id = 'foo_port_id'
port = {