Merge "In port_dead, handle case when port already deleted"
This commit is contained in:
@@ -937,7 +937,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)
|
||||
|
@@ -302,7 +302,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:
|
||||
@@ -319,6 +319,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.
|
||||
|
Reference in New Issue
Block a user