Discard port with ofport -1 in _get_ofport_moves
When libvirt (nova) detach a port on OVS bridge, two events are sent: * one event with 2 actions "old" and "new": a change on ofport (from a regular value to -1) * a second event with action "delete" If, for some reason, the second event is delayed, the rpc_loop iteration will consider this port as "updated" instead of "deleted". But, because ofport == -1, the port update will be discarded, and finally removed from port_info["current"]. As a result, on next iteration, the deletion wont be performed. Most of the time, we endup with some leftovers (like openflow rules, etc.) The purpose of this patch is very simple, when looping over ports in _get_ofport_moves, we will discards the ports that have ofport == -1, so the port will not be considered as updated and next iteration will be able to delete it correctly. Closes-Bug: #1992109 Change-Id: Ib4a7183867e1b21810b6915a475a234278bf884c Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
This commit is contained in:
parent
fb945cfa38
commit
f22aa5dfdd
|
@ -1685,6 +1685,11 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
|||
if name not in current:
|
||||
continue
|
||||
current_ofport = current[name]
|
||||
# NOTE(amorin) Discarding port that disappeared from ovs
|
||||
# This will avoid moving that port to skipped_devices
|
||||
# and forget about deleting it. See #lp-1992109
|
||||
if current_ofport == ovs_lib.INVALID_OFPORT:
|
||||
continue
|
||||
if ofport != current_ofport:
|
||||
port_moves.append(name)
|
||||
return port_moves
|
||||
|
|
|
@ -2512,6 +2512,14 @@ class TestOvsNeutronAgent(object):
|
|||
self.assertEqual(expected,
|
||||
self.agent._get_ofport_moves(current, previous))
|
||||
|
||||
def test__get_ofport_moves_invalid(self):
|
||||
previous = {'port1': 1, 'port2': 2}
|
||||
current = {'port1': -1, 'port2': 2}
|
||||
# we expect it to tell nothing
|
||||
expected = []
|
||||
self.assertEqual(expected,
|
||||
self.agent._get_ofport_moves(current, previous))
|
||||
|
||||
def test_update_stale_ofport_rules_clears_old(self):
|
||||
self.agent.prevent_arp_spoofing = True
|
||||
self.agent.vifname_to_ofport_map = {'port1': 1, 'port2': 2}
|
||||
|
|
Loading…
Reference in New Issue