Initialize ancillary_port_info dict as blank in OVS agent
The first assignment of ancillary_port_info was from the scan_ancillary_ports function which could result in an exception and result in ancillary_port_info being unbound for the port stats scan below. This patch just initializes ancillary_port_info as an empty dict so the port stats will always have an input. Closes-Bug: #1479265 Change-Id: I37084bf27d4c328a7b78ca71cf26813207697361
This commit is contained in:
parent
df35d21141
commit
3b18aa3e1f
|
@ -1520,6 +1520,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
|||
ovs_restarted = False
|
||||
while self._check_and_handle_signal():
|
||||
port_info = {}
|
||||
ancillary_port_info = {}
|
||||
start = time.time()
|
||||
LOG.debug("Agent rpc_loop - iteration:%d started",
|
||||
self.iter_num)
|
||||
|
@ -1628,8 +1629,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
|||
# Put the ports back in self.updated_port
|
||||
self.updated_ports |= updated_ports_copy
|
||||
sync = True
|
||||
ancillary_port_info = (ancillary_port_info if self.ancillary_brs
|
||||
else {})
|
||||
port_stats = self.get_port_stats(port_info, ancillary_port_info)
|
||||
self.loop_count_and_wait(start, port_stats)
|
||||
|
||||
|
|
|
@ -2135,11 +2135,11 @@ class TestOvsDvrNeutronAgent(object):
|
|||
pass
|
||||
self.assertTrue(all([x.called for x in reset_mocks]))
|
||||
|
||||
def test_scan_ports_failure(self):
|
||||
def _test_scan_ports_failure(self, scan_method_name):
|
||||
with mock.patch.object(self.agent,
|
||||
'check_ovs_status',
|
||||
return_value=constants.OVS_RESTARTED),\
|
||||
mock.patch.object(self.agent, 'scan_ports',
|
||||
mock.patch.object(self.agent, scan_method_name,
|
||||
side_effect=TypeError('broken')),\
|
||||
mock.patch.object(self.agent, '_agent_has_updates',
|
||||
return_value=True),\
|
||||
|
@ -2152,6 +2152,15 @@ class TestOvsDvrNeutronAgent(object):
|
|||
self.agent.state_rpc = mock.Mock()
|
||||
self.agent.rpc_loop(polling_manager=mock.Mock())
|
||||
|
||||
def test_scan_ports_failure(self):
|
||||
self._test_scan_ports_failure('scan_ports')
|
||||
|
||||
def test_scan_ancillary_ports_failure(self):
|
||||
with mock.patch.object(self.agent, 'scan_ports'):
|
||||
with mock.patch.object(self.agent, 'update_stale_ofport_rules'):
|
||||
self.agent.ancillary_brs = mock.Mock()
|
||||
self._test_scan_ports_failure('scan_ancillary_ports')
|
||||
|
||||
|
||||
class TestOvsDvrNeutronAgentOFCtl(TestOvsDvrNeutronAgent,
|
||||
ovs_test_base.OVSOFCtlTestBase):
|
||||
|
|
Loading…
Reference in New Issue