_bind_devices was making the assumption that the ports it
was operating had local VLAN map entries for their network.
This wasn't the case when a network was deleted right before
_bind_ports was called because the VLAN was reclaimed.
This patch just checks to see if the the network ID has an entry
in the map. If not, it skips the port. The port will be handled
on the next scan_ports iteration when the agent will discover that
the port is no longer defined on the plugin and it will be placed
in the DEAD vlan.
Change-Id: Ica51d727aceb41848fec0f4edbd16916365941ee
Closes-Bug: #
1452903
def _bind_devices(self, need_binding_ports):
for port_detail in need_binding_ports:
- lvm = self.local_vlan_map[port_detail['network_id']]
+ lvm = self.local_vlan_map.get(port_detail['network_id'])
+ if not lvm:
+ # network for port was deleted. skip this port since it
+ # will need to be handled as a DEAD port in the next scan
+ continue
port = port_detail['vif_port']
device = port_detail['device']
# Do not bind a port if it's already bound
def test_treat_devices_removed_ignores_missing_port(self):
self._mock_treat_devices_removed(False)
+ def test_bind_port_with_missing_network(self):
+ self.agent._bind_devices([{'network_id': 'non-existent'}])
+
def _test_process_network_ports(self, port_info):
with contextlib.nested(
mock.patch.object(self.agent.sg_agent, "setup_port_filters"),