Skip to content

Commit 1fe05c5

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 b4f7c9d commit 1fe05c5

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
@@ -1732,15 +1732,6 @@ def prevent_l3_port_deletion(self, context, port_id, port=None):
17321732
return
17331733
if port['device_owner'] not in self.router_device_owners:
17341734
return
1735-
# Raise port in use only if the port has IP addresses
1736-
# Otherwise it's a stale port that can be removed
1737-
fixed_ips = port['fixed_ips']
1738-
if not fixed_ips:
1739-
LOG.debug("Port %(port_id)s has owner %(port_owner)s, but "
1740-
"no IP address, so it can be deleted",
1741-
{'port_id': port['id'],
1742-
'port_owner': port['device_owner']})
1743-
return
17441735
# NOTE(kevinbenton): we also check to make sure that the
17451736
# router still exists. It's possible for HA router interfaces
17461737
# 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)