Merge "Fix error when deleting a non-existent port"

This commit is contained in:
Zuul 2018-06-25 17:37:00 +00:00 committed by Gerrit Code Review
commit 7c55187b87
3 changed files with 22 additions and 0 deletions

View File

@ -338,6 +338,9 @@ def remove_neutron_ports(task, params):
try:
client.delete_port(port['id'])
# NOTE(mgoddard): Ignore if the port was deleted by nova.
except neutron_exceptions.PortNotFoundClient:
LOG.info('Port %s was not found while deleting.', port['id'])
except neutron_exceptions.NeutronClientException as e:
msg = (_('Could not remove VIF %(vif)s of node %(node)s, possibly '
'a network issue: %(exc)s') %

View File

@ -467,6 +467,18 @@ class TestNeutronNetworkActions(db_base.DbTestCase):
self.client_mock.delete_port.assert_called_once_with(
self.neutron_port['id'])
def test_remove_neutron_ports_delete_race(self):
with task_manager.acquire(self.context, self.node.uuid) as task:
self.client_mock.delete_port.side_effect = \
neutron_client_exc.PortNotFoundClient
self.client_mock.list_ports.return_value = {
'ports': [self.neutron_port]}
neutron.remove_neutron_ports(task, {'param': 'value'})
self.client_mock.list_ports.assert_called_once_with(
**{'param': 'value'})
self.client_mock.delete_port.assert_called_once_with(
self.neutron_port['id'])
def test_get_node_portmap(self):
with task_manager.acquire(self.context, self.node.uuid) as task:
portmap = neutron.get_node_portmap(task)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes an issue seen during node tear down where a port being deleted by the
Bare Metal service could be deleted by the Compute service, leading to an
unhandled error from the Networking service. See `story 2002637
<https://storyboard.openstack.org/#!/story/2002637>`__ for further details.