diff options
author | Vasyl Saienko <vsaienko@mirantis.com> | 2017-03-30 11:18:59 +0300 |
---|---|---|
committer | Pierre Riteau <priteau@uchicago.edu> | 2017-10-05 17:21:44 +0100 |
commit | 71d1c26376c84783e2c0176b9222e0343df701eb (patch) | |
tree | 517326091a84a9471e05d126094bc03d8930381b | |
parent | dfa2fb6dcd4e5030d5e1cac52ddbf43c9a181950 (diff) | |
download | ironic-71d1c26376c84783e2c0176b9222e0343df701eb.tar.gz |
Skip PortNotFound when unbinding port
There might be cases when user deleted port before doing vif_detach.
With this patch info message will be shown in the logs for such cases.
Change-Id: I60deab450b427f1a1b4ccb0bb5963ec30d255d48
Closes-Bug: #1685592
(cherry picked from commit 940c87d6c49be181d969e85d343b745149b6db10)
-rw-r--r-- | ironic/common/neutron.py | 3 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_neutron.py | 18 | ||||
-rw-r--r-- | releasenotes/notes/ignore-port-not-found-when-unbinding-94fb63988e98cb21.yaml | 8 |
3 files changed, 29 insertions, 0 deletions
diff --git a/ironic/common/neutron.py b/ironic/common/neutron.py index bf4294274..a9918dcb4 100644 --- a/ironic/common/neutron.py +++ b/ironic/common/neutron.py @@ -88,6 +88,9 @@ def unbind_neutron_port(port_id, client=None): try: client.update_port(port_id, body) + # NOTE(vsaienko): Ignore if port was deleted before calling vif detach. + except neutron_exceptions.PortNotFoundClient: + LOG.info('Port %s was not found while unbinding.', port_id) except neutron_exceptions.NeutronClientException as e: msg = (_('Unable to clear binding profile for ' 'neutron port %(port_id)s. Error: ' diff --git a/ironic/tests/unit/common/test_neutron.py b/ironic/tests/unit/common/test_neutron.py index 737667c51..5bba84d50 100644 --- a/ironic/tests/unit/common/test_neutron.py +++ b/ironic/tests/unit/common/test_neutron.py @@ -686,3 +686,21 @@ class TestUnbindPort(base.TestCase): mock_client.assert_called_once_with() mock_client.return_value.update_port.assert_called_once_with(port_id, body) + + @mock.patch.object(neutron, 'LOG') + def test_unbind_neutron_port_not_found(self, mock_log, mock_client): + port_id = 'fake-port-id' + mock_client.return_value.update_port.side_effect = ( + neutron_client_exc.PortNotFoundClient()) + body = { + 'port': { + 'binding:host_id': '', + 'binding:profile': {} + } + } + neutron.unbind_neutron_port(port_id) + mock_client.assert_called_once_with() + mock_client.return_value.update_port.assert_called_once_with(port_id, + body) + mock_log.info.assert_called_once_with('Port %s was not found while ' + 'unbinding.', port_id) diff --git a/releasenotes/notes/ignore-port-not-found-when-unbinding-94fb63988e98cb21.yaml b/releasenotes/notes/ignore-port-not-found-when-unbinding-94fb63988e98cb21.yaml new file mode 100644 index 000000000..30e63af7b --- /dev/null +++ b/releasenotes/notes/ignore-port-not-found-when-unbinding-94fb63988e98cb21.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - Fixes a failure when deploying a node. This happened when a port or port + group's internal_info['tenant_vif_port_id'] still existed after the + corresponding neutron port was removed and prior to deletion of the + instance, causing future deployments of the bare metal node to fail. The + situation is now logged and does not block future deployments. See + https://bugs.launchpad.net/ironic/+bug/1685592 for details. |