Trivial: avoid KeyError while processing ports
The Neutron OVS agent logs can get flooded with KeyErrors as the '_get_port_info' method skips the added/removed dict items if no ports have been added/removed, which are expected to be present, even if those are just empty sets. This change ensures that those port info dict fields are always set. Closes-Bug: #1783556 Change-Id: I9e5325aa2d8525231353ba451e8ea895be51b1ca
This commit is contained in:
parent
ca13e651c9
commit
da5b13df2b
@ -1263,7 +1263,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
|
||||
def _get_port_info(self, registered_ports, cur_ports,
|
||||
readd_registered_ports):
|
||||
port_info = {'current': cur_ports}
|
||||
port_info = {'current': cur_ports,
|
||||
'added': set(),
|
||||
'removed': set()}
|
||||
# FIXME(salv-orlando): It's not really necessary to return early
|
||||
# if nothing has changed.
|
||||
if not readd_registered_ports and cur_ports == registered_ports:
|
||||
|
@ -387,7 +387,9 @@ class TestOvsNeutronAgent(object):
|
||||
def test_scan_ports_returns_current_only_for_unchanged_ports(self):
|
||||
vif_port_set = set([1, 3])
|
||||
registered_ports = set([1, 3])
|
||||
expected = {'current': vif_port_set}
|
||||
expected = {'current': vif_port_set,
|
||||
'added': set(),
|
||||
'removed': set()}
|
||||
actual = self.mock_scan_ports(vif_port_set, registered_ports)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@ -438,7 +440,8 @@ class TestOvsNeutronAgent(object):
|
||||
vif_port_set = set([1, 2, 3])
|
||||
registered_ports = set([1, 2, 3])
|
||||
updated_ports = set([2])
|
||||
expected = dict(current=vif_port_set, updated=set([2]))
|
||||
expected = dict(current=vif_port_set, updated=set([2]),
|
||||
added=set(), removed=set())
|
||||
actual = self.mock_scan_ports(vif_port_set, registered_ports,
|
||||
updated_ports)
|
||||
self.assertEqual(expected, actual)
|
||||
@ -2452,7 +2455,9 @@ class AncillaryBridgesTest(object):
|
||||
def test_scan_ancillary_ports_returns_cur_only_for_unchanged_ports(self):
|
||||
vif_port_set = set([1, 2])
|
||||
registered_ports = set([1, 2])
|
||||
expected = dict(current=vif_port_set)
|
||||
expected = dict(current=vif_port_set,
|
||||
added=set(),
|
||||
removed=set())
|
||||
actual = self.mock_scan_ancillary_ports(vif_port_set, registered_ports)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user