When deleting floating IP catch PortNotFound
If we try to delete a VM and to delete the floating IP associated with the VM at the same time, depending on the order according to which these requests are processed Neutron might fail in the deletion of the floating IP, raising a PortNotFound error. This happens because Neutron notifies Nova of the network change event and it tries to get the port to which the FIP is associated. If the port is not there, Neutron shouldn't raise, it shouldn't send any notification. Change-Id: Ic72313ad1f787b3cb528e806c843f1fd01eb12f2 Closes-bug: #1586931
This commit is contained in:
parent
78dc79146f
commit
6e275e3857
|
@ -15,6 +15,7 @@
|
|||
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as exc
|
||||
from novaclient import client as nova_client
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
|
@ -158,7 +159,12 @@ class Notifier(object):
|
|||
return
|
||||
|
||||
ctx = context.get_admin_context()
|
||||
port = self._plugin.get_port(ctx, port_id)
|
||||
try:
|
||||
port = self._plugin.get_port(ctx, port_id)
|
||||
except exc.PortNotFound:
|
||||
LOG.debug("Port %s was deleted, no need to send any "
|
||||
"notification", port_id)
|
||||
return
|
||||
|
||||
if port and self._is_compute_port(port):
|
||||
if action == 'delete_port':
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import mock
|
||||
from neutron_lib import constants as n_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
|
@ -175,6 +176,17 @@ class TestNovaNotify(base.BaseTestCase):
|
|||
'delete_floatingip', {}, returned_obj)
|
||||
self.assertEqual(expected_event, event)
|
||||
|
||||
def test_delete_floatingip_deleted_port_no_notify(self):
|
||||
port_id = 'bee50827-bcee-4cc8-91c1-a27b0ce54222'
|
||||
with mock.patch.object(
|
||||
self.nova_notifier._plugin_ref, 'get_port',
|
||||
side_effect=n_exc.PortNotFound(port_id=port_id)):
|
||||
returned_obj = {'floatingip':
|
||||
{'port_id': port_id}}
|
||||
event = self.nova_notifier.create_port_changed_event(
|
||||
'delete_floatingip', {}, returned_obj)
|
||||
self.assertIsNone(event)
|
||||
|
||||
def test_delete_floatingip_no_port_id_no_notify(self):
|
||||
returned_obj = {'floatingip':
|
||||
{'port_id': None}}
|
||||
|
|
Loading…
Reference in New Issue