]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
In port_dead, handle case when port already deleted
authorRamu Ramamurthy <ramu.ramamurthy@us.ibm.com>
Thu, 19 Nov 2015 23:43:19 +0000 (18:43 -0500)
committerRamu Ramamurthy <ramu.ramamurthy@us.ibm.com>
Mon, 30 Nov 2015 18:46:05 +0000 (13:46 -0500)
db_get_val can return None if the port got deleted concurrently.
In this case there is no need to mark it dead and add drop flow for it.

Change-Id: I5ef9665770df3a9bbaf79049b219fadd73e20309
Partial-Bug: #1493414

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

index ea51b95af0d7dd215d061bd4b9afe1caa2ae8c30..dd7791f0b5c58a74da289592673eaa2df9f78078 100644 (file)
@@ -952,7 +952,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         # Don't kill a port if it's already dead
         cur_tag = self.int_br.db_get_val("Port", port.port_name, "tag",
                                          log_errors=log_errors)
-        if cur_tag != DEAD_VLAN_TAG:
+        if cur_tag and cur_tag != DEAD_VLAN_TAG:
             self.int_br.set_db_attribute("Port", port.port_name, "tag",
                                          DEAD_VLAN_TAG, log_errors=log_errors)
             self.int_br.drop_port(in_port=port.ofport)
index 71b5637f8f9350369b16128fbc018331098bfea3..fd6d9762c4e5298ace92a2c8b439a535826db6cf 100644 (file)
@@ -312,7 +312,7 @@ class TestOvsNeutronAgent(object):
         with mock.patch.object(self.agent, 'int_br') as int_br:
             int_br.db_get_val.return_value = cur_tag
             self.agent.port_dead(port)
-        if cur_tag == self.mod_agent.DEAD_VLAN_TAG:
+        if cur_tag is None or cur_tag == self.mod_agent.DEAD_VLAN_TAG:
             self.assertFalse(int_br.set_db_attribute.called)
             self.assertFalse(int_br.drop_port.called)
         else:
@@ -329,6 +329,9 @@ class TestOvsNeutronAgent(object):
     def test_port_dead_with_port_already_dead(self):
         self._test_port_dead(self.mod_agent.DEAD_VLAN_TAG)
 
+    def test_port_dead_with_valid_tag(self):
+        self._test_port_dead(cur_tag=1)
+
     def mock_scan_ports(self, vif_port_set=None, registered_ports=None,
                         updated_ports=None, port_tags_dict=None, sync=False):
         if port_tags_dict is None:  # Because empty dicts evaluate as False.