From bfed31bb4c599b7063da80798db8078a64c13368 Mon Sep 17 00:00:00 2001 From: Mark Goddard <mark@stackhpc.com> Date: Thu, 21 Jun 2018 16:16:45 +0100 Subject: [PATCH] Fix error when deleting a non-existent port 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. This change simply ignores the PortNotFoundClient exception raises, as is done when attempting to unbind a port that does not exist. See [1] for details. [1] https://storyboard.openstack.org/#!/story/2002637> Change-Id: Icd2aaa1276e75f08f99553bbc9a873102d896fb9 Story: 2002637 Task: 22285 --- ironic/common/neutron.py | 3 +++ ironic/tests/unit/common/test_neutron.py | 12 ++++++++++++ .../notes/story-2002637-4825d60b096e475b.yaml | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 releasenotes/notes/story-2002637-4825d60b096e475b.yaml diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py index fa2ebc813a..986bd9452a 100644 --- a/ironic/common/neutron.py +++ b/ironic/common/neutron.py @@ -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') % diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index 8ff1ad936b..e58cac646c 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -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) diff --git a/releasenotes/notes/story-2002637-4825d60b096e475b.yaml b/releasenotes/notes/story-2002637-4825d60b096e475b.yaml new file mode 100644 index 0000000000..cd86d7e859 --- /dev/null +++ b/releasenotes/notes/story-2002637-4825d60b096e475b.yaml @@ -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.