In port_dead, handle case when port already deleted
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
This commit is contained in:
parent
a93b889ae5
commit
76cc53c611
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue