Ensure that tunnels are fully reset on ovs restart

When the l2population mechanism driver is enabled, if ovs is restarted
tunnel ports are not re-configured in full due to stale ofport handles
in the OVS agent.

Reset all handles when OVS is restarted to ensure that tunnels are
fully recreated in this situation.

Change-Id: If0e034a034a7f000a1c58aa8a43d2c857dee6582
Closes-bug: #1460164
(cherry picked from commit 17c14977ce)
This commit is contained in:
James Page 2015-12-18 15:02:11 +00:00
parent 1e52b28cc9
commit 05f8099a68
2 changed files with 29 additions and 4 deletions

View File

@ -230,9 +230,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.setup_physical_bridges(self.bridge_mappings)
self.local_vlan_map = {}
self.tun_br_ofports = {p_const.TYPE_GENEVE: {},
p_const.TYPE_GRE: {},
p_const.TYPE_VXLAN: {}}
self._reset_tunnel_ofports()
self.polling_interval = polling_interval
self.minimize_polling = minimize_polling
@ -363,6 +361,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.available_local_vlans.update(self._local_vlan_hints.values())
self._local_vlan_hints = {}
def _reset_tunnel_ofports(self):
self.tun_br_ofports = {p_const.TYPE_GENEVE: {},
p_const.TYPE_GRE: {},
p_const.TYPE_VXLAN: {}}
def setup_rpc(self):
self.agent_id = 'ovs-agent-%s' % self.conf.host
self.topic = topics.AGENT
@ -1695,6 +1698,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.setup_integration_br()
self.setup_physical_bridges(self.bridge_mappings)
if self.enable_tunneling:
self._reset_tunnel_ofports()
self.setup_tunnel_br()
self.setup_tunnel_br_flows()
tunnel_sync = True

View File

@ -1359,6 +1359,12 @@ class TestOvsNeutronAgent(object):
self.agent.tunnel_delete(context=None, **kwargs)
self.assertTrue(clean_tun_fn.called)
def test_reset_tunnel_ofports(self):
tunnel_handles = self.agent.tun_br_ofports
self.agent.tun_br_ofports = {'gre': {'10.10.10.10': '1'}}
self.agent._reset_tunnel_ofports()
self.assertEqual(self.agent.tun_br_ofports, tunnel_handles)
def _test_ovs_status(self, *args):
reply2 = {'current': set(['tap0']),
'added': set(['tap2']),
@ -1368,6 +1374,8 @@ class TestOvsNeutronAgent(object):
'added': set([]),
'removed': set(['tap0'])}
self.agent.enable_tunneling = True
with mock.patch.object(async_process.AsyncProcess, "_spawn"),\
mock.patch.object(log.KeywordArgumentAdapter,
'exception') as log_exception,\
@ -1387,7 +1395,15 @@ class TestOvsNeutronAgent(object):
self.mod_agent.OVSNeutronAgent,
'update_stale_ofport_rules') as update_stale, \
mock.patch.object(self.mod_agent.OVSNeutronAgent,
'cleanup_stale_flows') as cleanup:
'cleanup_stale_flows') as cleanup, \
mock.patch.object(self.mod_agent.OVSNeutronAgent,
'setup_tunnel_br') as setup_tunnel_br,\
mock.patch.object(
self.mod_agent.OVSNeutronAgent,
'setup_tunnel_br_flows') as setup_tunnel_br_flows,\
mock.patch.object(
self.mod_agent.OVSNeutronAgent,
'_reset_tunnel_ofports') as reset_tunnel_ofports:
log_exception.side_effect = Exception(
'Fake exception to get out of the loop')
scan_ports.side_effect = [reply2, reply3]
@ -1413,6 +1429,11 @@ class TestOvsNeutronAgent(object):
# re-setup the bridges
setup_int_br.assert_has_calls([mock.call()])
setup_phys_br.assert_has_calls([mock.call({})])
# Ensure that tunnel handles are reset and bridge
# and flows reconfigured.
self.assertTrue(reset_tunnel_ofports.called)
self.assertTrue(setup_tunnel_br_flows.called)
self.assertTrue(setup_tunnel_br.called)
def test_ovs_status(self):
self._test_ovs_status(constants.OVS_NORMAL,