Skip to content

Commit 5dde1b0

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Don't allow deletion of the router ports without IP addresses" into stable/2023.1
2 parents 8660a4f + 8546131 commit 5dde1b0

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
@@ -1738,15 +1738,6 @@ def prevent_l3_port_deletion(self, context, port_id, port=None):
17381738
return
17391739
if port['device_owner'] not in self.router_device_owners:
17401740
return
1741-
# Raise port in use only if the port has IP addresses
1742-
# Otherwise it's a stale port that can be removed
1743-
fixed_ips = port['fixed_ips']
1744-
if not fixed_ips:
1745-
LOG.debug("Port %(port_id)s has owner %(port_owner)s, but "
1746-
"no IP address, so it can be deleted",
1747-
{'port_id': port['id'],
1748-
'port_owner': port['device_owner']})
1749-
return
17501741
# NOTE(kevinbenton): we also check to make sure that the
17511742
# router still exists. It's possible for HA router interfaces
17521743
# 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)