]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Minor improvement in port_bound operation
authorarmando-migliaccio <armamig@gmail.com>
Thu, 22 Oct 2015 00:47:47 +0000 (17:47 -0700)
committerarmando-migliaccio <armamig@gmail.com>
Thu, 22 Oct 2015 00:57:27 +0000 (17:57 -0700)
By returning the need for binding, the (no-op) port processing
is skipped in the main sync loop. In fact, the port is already
detected as deleted and avoiding going over it again will save
us one log message, and thus many, many, many, many bytes over
time in logs.openstack.org.

If this is not an improvement, I don't what is.

Related-bug: 1455320

Change-Id: I4ef30bed6a1619f5980c3e61ee23ffb808c2c4f0

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

index 4fb4099fe808c5398149b739bf8b4cbb0520b4f7..5d34b4fb9b1130a532062a21b083fa110b3761b1 100644 (file)
@@ -804,7 +804,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                 LOG.error(_LE("Expected port %s not found"), port.vif_id)
             else:
                 LOG.debug("Unable to get config for port %s", port.vif_id)
-            return
+            return False
 
         vlan_mapping = {'net_uuid': net_uuid,
                         'network_type': network_type,
@@ -814,6 +814,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         port_other_config.update(vlan_mapping)
         self.int_br.set_db_attribute("Port", port.port_name, "other_config",
                                      port_other_config)
+        return True
 
     def _bind_devices(self, need_binding_ports):
         devices_up = []
@@ -1276,9 +1277,10 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
                          "and might not be able to transmit"), vif_port.vif_id)
         if vif_port:
             if admin_state_up:
-                self.port_bound(vif_port, network_id, network_type,
-                                physical_network, segmentation_id,
-                                fixed_ips, device_owner, ovs_restarted)
+                port_needs_binding = self.port_bound(
+                    vif_port, network_id, network_type,
+                    physical_network, segmentation_id,
+                    fixed_ips, device_owner, ovs_restarted)
             else:
                 self.port_dead(vif_port)
                 port_needs_binding = False
index 0e5761d254ed56c9749a1687066ec4c3445e3d53..0a2b68fd4ef08cd37b17da5ff2d0aba8c6baba4b 100644 (file)
@@ -165,16 +165,19 @@ class TestOvsNeutronAgent(object):
         with mock.patch.object(self.agent, 'int_br', autospec=True) as int_br:
             int_br.db_get_val.return_value = db_get_val
             int_br.set_db_attribute.return_value = True
-            self.agent.port_bound(port, net_uuid, 'local', None, None,
-                                  fixed_ips, "compute:None", False)
+            needs_binding = self.agent.port_bound(
+                port, net_uuid, 'local', None, None,
+                fixed_ips, "compute:None", False)
         if db_get_val is None:
             self.assertEqual(0, int_br.set_db_attribute.call_count)
+            self.assertFalse(needs_binding)
         else:
             vlan_mapping = {'net_uuid': net_uuid,
                             'network_type': 'local',
                             'physical_network': None}
             int_br.set_db_attribute.assert_called_once_with(
                 "Port", mock.ANY, "other_config", vlan_mapping)
+            self.assertTrue(needs_binding)
 
     def test_datapath_type_system(self):
         # verify kernel datapath is default