Prevent router_ha_interface port from being removed via API

If someone removes the port with device owner router_ha_interface,
then we can get unexpected router behavior like doubling
arp response packets. This patch prohibits removing such a port.

Closes-Bug: #2008270
Change-Id: Ief031801c1a3e3dd64e6cbf65e27f04f2bef9cba
This commit is contained in:
Anton Kurbatov 2023-02-23 15:07:11 +00:00
parent c178c28fb8
commit e68e4162ce
2 changed files with 16 additions and 0 deletions

View File

@ -68,6 +68,10 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
router_az_db.RouterAvailabilityZoneMixin):
"""Mixin class to add high availability capability to routers."""
router_device_owners = (
l3_dvr_db.L3_NAT_with_dvr_db_mixin.router_device_owners +
(constants.DEVICE_OWNER_ROUTER_HA_INTF, ))
def _verify_configuration(self):
self.ha_cidr = cfg.CONF.l3_ha_net_cidr
try:

View File

@ -669,6 +669,18 @@ class L3HATestCase(L3HATestFramework):
self.admin_ctx, ports[0]['id'],
port)
def test_delete_router_ha_interface_port(self):
router = self._create_router()
network = self.plugin.get_ha_network(self.admin_ctx,
router['tenant_id'])
binding = self.plugin.add_ha_port(
self.admin_ctx, router['id'], network.network_id,
router['tenant_id'])
self.assertRaises(n_exc.ServicePortInUse,
self.core_plugin.delete_port,
self.admin_ctx, binding.port_id)
def test_create_ha_network_tenant_binding_raises_duplicate(self):
router = self._create_router()
network = self.plugin.get_ha_network(self.admin_ctx,