Initialize port_info dict as blank in OVS agent
The first assignment of port_info was from the scan_ports function which could result in an exception and result in port_info being unbound for the port stats scan below. This patch just initializes port_info as an empty dict so the port stats will always have an input. Closes-Bug: #1479105 Change-Id: I017a6dd334e2673072c977cc13b73e8cceb16712
This commit is contained in:
parent
e6e54f4477
commit
4021fe30a9
|
@ -1516,6 +1516,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
|||
tunnel_sync = True
|
||||
ovs_restarted = False
|
||||
while self._check_and_handle_signal():
|
||||
port_info = {}
|
||||
start = time.time()
|
||||
LOG.debug("Agent rpc_loop - iteration:%d started",
|
||||
self.iter_num)
|
||||
|
|
|
@ -2104,6 +2104,23 @@ class TestOvsDvrNeutronAgent(object):
|
|||
pass
|
||||
self.assertTrue(all([x.called for x in reset_mocks]))
|
||||
|
||||
def test_scan_ports_failure(self):
|
||||
with mock.patch.object(self.agent,
|
||||
'check_ovs_status',
|
||||
return_value=constants.OVS_RESTARTED),\
|
||||
mock.patch.object(self.agent, 'scan_ports',
|
||||
side_effect=TypeError('broken')),\
|
||||
mock.patch.object(self.agent, '_agent_has_updates',
|
||||
return_value=True),\
|
||||
mock.patch.object(self.agent, '_check_and_handle_signal',
|
||||
side_effect=[True, False]):
|
||||
# block RPC calls and bridge calls
|
||||
self.agent.setup_physical_bridges = mock.Mock()
|
||||
self.agent.setup_integration_br = mock.Mock()
|
||||
self.agent.reset_tunnel_br = mock.Mock()
|
||||
self.agent.state_rpc = mock.Mock()
|
||||
self.agent.rpc_loop(polling_manager=mock.Mock())
|
||||
|
||||
|
||||
class TestOvsDvrNeutronAgentOFCtl(TestOvsDvrNeutronAgent,
|
||||
ovs_test_base.OVSOFCtlTestBase):
|
||||
|
|
Loading…
Reference in New Issue