Check for None in _get_agent_fdb for agent
get_agent_by_host can return None in the l2pop
driver so we need to check for that case before
we blindly try to decode configuration values on
the result.
There are a couple of cases that can lead to this.
* The deployment can be misconfigured and is missing
either a tunneling_ip option for the agent on a
host or is missing an L2 agent with that host_id
entirely.
* Multiple mech drivers are in use and a port is being
deleted from an agentless host.
Related-Bug: #1533013
Closes-Bug: #1672564
Change-Id: I1e79f600172edad1e31e8231a0a6a2c55f46804c
(cherry picked from commit c7fb24b3cb
)
This commit is contained in:
parent
085afaa649
commit
f15031f406
|
@ -312,6 +312,10 @@ class L2populationMechanismDriver(api.MechanismDriver):
|
|||
|
||||
agent = l2pop_db.get_agent_by_host(session,
|
||||
agent_host)
|
||||
if not agent:
|
||||
LOG.warning(_LW("Unable to retrieve active L2 agent on host %s"),
|
||||
agent_host)
|
||||
return
|
||||
if not self._validate_segment(segment, port['id'], agent):
|
||||
return
|
||||
|
||||
|
|
|
@ -1098,15 +1098,24 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
|
|||
self.assertTrue(upd_port_down.called)
|
||||
|
||||
def test_delete_unbound_port(self):
|
||||
self._test_delete_port_handles_agentless_host_id(None)
|
||||
|
||||
def test_delete_port_bound_to_agentless_host(self):
|
||||
self._test_delete_port_handles_agentless_host_id('test')
|
||||
|
||||
def _test_delete_port_handles_agentless_host_id(self, host):
|
||||
l2pop_mech = l2pop_mech_driver.L2populationMechanismDriver()
|
||||
l2pop_mech.initialize()
|
||||
|
||||
with self.port() as port:
|
||||
port['port'][portbindings.HOST_ID] = host
|
||||
bindings = [mock.Mock()]
|
||||
port_context = driver_context.PortContext(
|
||||
self.driver, self.context, port['port'],
|
||||
self.driver.get_network(
|
||||
self.context, port['port']['network_id']),
|
||||
None, None)
|
||||
None, bindings)
|
||||
mock.patch.object(port_context, '_expand_segment').start()
|
||||
# The point is to provide coverage and to assert that no exceptions
|
||||
# are raised.
|
||||
l2pop_mech.delete_port_postcommit(port_context)
|
||||
|
|
Loading…
Reference in New Issue