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: Ic3c5073130a4839f27692db1862100bdd7dfca1e
This commit is contained in:
parent
22e8bb2b4d
commit
940c87d6c4
@ -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: '
|
||||
|
@ -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)
|
||||
|
@ -330,6 +330,8 @@ class BaremetalStandaloneScenarioTest(BaremetalStandaloneManager):
|
||||
def resource_cleanup(cls):
|
||||
cls.cleanup_floating_ip(cls.node_ip)
|
||||
vifs = cls.get_node_vifs(cls.node['uuid'])
|
||||
# Remove ports before deleting node, to catch regression for cases
|
||||
# when user did this prior unprovision node.
|
||||
for vif in vifs:
|
||||
cls.ports_client.delete_port(vif)
|
||||
cls.terminate_node(cls.node['uuid'])
|
||||
|
Loading…
Reference in New Issue
Block a user