Check for unbound ports in L3 RPC handler

The handler was making the incorrect assumption that once a
host_id was set, a port which failed to bind could only be in
the 'binding_failed' state. So it would not try to rebind ports
that encountered an exeption during port binding commit that left
them in the unbound state.

Change-Id: I28bbeda5fed4275ea38e27308518f89df9ab4eff
Closes-Bug: #1648879
(cherry picked from commit a5a8a37344)
This commit is contained in:
Kevin Benton 2016-12-09 11:49:09 -08:00 committed by Ihar Hrachyshka
parent 8a89cce6fc
commit 51f9ea667a
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 = {