]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Check for missing network in _bind_devices
authorKevin Benton <blak111@gmail.com>
Sun, 3 May 2015 06:10:52 +0000 (23:10 -0700)
committerKevin Benton <kevinbenton@buttewifi.com>
Thu, 7 May 2015 22:56:56 +0000 (22:56 +0000)
_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

neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/plugins/openvswitch/agent/test_ovs_neutron_agent.py

index 90f15d51567078b99d29bc9aa27693a2e2f36286..7e7d377562c8de242982a2afd8a5a32603693299 100644 (file)
@@ -733,7 +733,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
 
     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
index d201574527e7f9e560a33265139802d50c86106b..0eeaaa11a870707633c063d6fd53946df0779deb 100644 (file)
@@ -431,6 +431,9 @@ class TestOvsNeutronAgent(base.BaseTestCase):
     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"),