Skip to content

Commit 4f043fb

Browse files
committed
Don't allow deletion of the router ports without IP addresses
This patch effectively reverts old patch [1]. From now on it will be not allowed to directly remove router ports which don't have fixed IPs assigned. Such ports will be treated as any other ports connected to the routers. Originally [1] was introduced to allow cleanup of the router ports for which subnets were deleted. But now it's not needed anymore as we prevent deletion of subnet if there are any ports with IP allocated from that subnet. Closes-bug: #2025056 [1] https://review.opendev.org/c/openstack/neutron/+/20424 Change-Id: I1a3723ae999fefb5dcbe3a60cf1a4902da9f0265 (cherry picked from commit 32d589f)
1 parent 73ba302 commit 4f043fb

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

neutron/db/l3_db.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,15 +1730,6 @@ def prevent_l3_port_deletion(self, context, port_id, port=None):
17301730
return
17311731
if port['device_owner'] not in self.router_device_owners:
17321732
return
1733-
# Raise port in use only if the port has IP addresses
1734-
# Otherwise it's a stale port that can be removed
1735-
fixed_ips = port['fixed_ips']
1736-
if not fixed_ips:
1737-
LOG.debug("Port %(port_id)s has owner %(port_owner)s, but "
1738-
"no IP address, so it can be deleted",
1739-
{'port_id': port['id'],
1740-
'port_owner': port['device_owner']})
1741-
return
17421733
# NOTE(kevinbenton): we also check to make sure that the
17431734
# router still exists. It's possible for HA router interfaces
17441735
# to remain after the router is deleted if they encounter an

neutron/tests/unit/db/test_l3_db.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ def test_prevent_l3_port_no_fixed_ips(self, gp):
290290
# without fixed IPs is allowed
291291
gp.return_value.get_port.return_value = {
292292
'device_owner': n_const.DEVICE_OWNER_ROUTER_INTF, 'fixed_ips': [],
293-
'id': 'f'
293+
'device_id': '44', 'id': 'f',
294294
}
295-
self.db.prevent_l3_port_deletion(None, None)
295+
with testtools.ExpectedException(n_exc.ServicePortInUse):
296+
self.db.prevent_l3_port_deletion(mock.Mock(), None)
296297

297298
@mock.patch.object(directory, 'get_plugin')
298299
def test_prevent_l3_port_no_router(self, gp):

0 commit comments

Comments
 (0)