for port_id in port_ids:
try:
self.delete_port(context, port_id)
- except exc.PortNotFound:
+ except (exc.PortNotFound, sa_exc.ObjectDeletedError):
# concurrent port deletion can be performed by
# release_dhcp_port caused by concurrent subnet_delete
LOG.info(_LI("Port %s was deleted concurrently"), port_id)
for subnet_id in subnet_ids:
try:
self.delete_subnet(context, subnet_id)
- except exc.SubnetNotFound:
+ except (exc.SubnetNotFound, sa_exc.ObjectDeletedError):
LOG.info(_LI("Subnet %s was deleted concurrently"),
subnet_id)
except Exception:
from oslo_db import exception as db_exc
from oslo_utils import uuidutils
+from sqlalchemy.orm import exc as sqla_exc
from neutron.callbacks import registry
from neutron.common import constants
side_effect=exc.PortNotFound(port_id="123")):
plugin._delete_ports(mock.MagicMock(), [mock.MagicMock()])
+ with mock.patch.object(plugin, "delete_port",
+ side_effect=sqla_exc.ObjectDeletedError(None)):
+ plugin._delete_ports(mock.MagicMock(), [mock.MagicMock()])
+
def test_subnet_delete_helper_tolerates_failure(self):
plugin = manager.NeutronManager.get_plugin()
with mock.patch.object(plugin, "delete_subnet",
side_effect=exc.SubnetNotFound(subnet_id="1")):
plugin._delete_subnets(mock.MagicMock(), [mock.MagicMock()])
+ with mock.patch.object(plugin, "delete_subnet",
+ side_effect=sqla_exc.ObjectDeletedError(None)):
+ plugin._delete_subnets(mock.MagicMock(), [mock.MagicMock()])
+
def _create_and_verify_networks(self, networks):
for net_idx, net in enumerate(networks):
# create