Delete VRRP and MGT ports on router delete
These ports are left behind when a router is deleted.
Stale VRRP ports prevent a tenant from deleting their own networks
as it is owned by the service VM but active and invisible to the tenant.
MGT ports dont block net delete but should be cleaned up regardless.
Closes-bug: #1491593
(manually adapted from 379a150a99)
Change-Id: Ib96a730825468822fe12a2b0b402e2d18fd33c4e
Signed-off-by: Rosario Di Somma <rosario.disomma@dreamhost.com>
This commit is contained in:
@@ -396,6 +396,37 @@ class TestExternalPort(unittest.TestCase):
|
||||
mock_client.delete_port.assert_called_once_with(
|
||||
self.ROUTER['ports'][0]['id'])
|
||||
|
||||
@mock.patch('akanda.rug.api.neutron.AkandaExtClientWrapper')
|
||||
def test_delete_vrrp_ports(self, client_wrapper):
|
||||
conf = mock.Mock()
|
||||
neutron_wrapper = neutron.Neutron(conf)
|
||||
neutron_wrapper.api_client.list_ports = mock.Mock(
|
||||
return_value={
|
||||
'ports': [{'id': 'fake_port_id'}]
|
||||
}
|
||||
)
|
||||
neutron_wrapper.api_client.delete_port = mock.Mock()
|
||||
neutron_wrapper.delete_vrrp_port(object_id='foo')
|
||||
neutron_wrapper.api_client.list_ports.assert_called_with(
|
||||
name='AKANDA:VRRP:foo'
|
||||
)
|
||||
neutron_wrapper.api_client.delete_port.assert_called_with(
|
||||
'fake_port_id')
|
||||
|
||||
@mock.patch('akanda.rug.api.neutron.AkandaExtClientWrapper')
|
||||
def test_delete_vrrp_ports_not_found(self, client_wrapper):
|
||||
conf = mock.Mock()
|
||||
neutron_wrapper = neutron.Neutron(conf)
|
||||
neutron_wrapper.api_client.list_ports = mock.Mock(
|
||||
return_value={'ports': []}
|
||||
)
|
||||
neutron_wrapper.api_client.delete_port = mock.Mock()
|
||||
neutron_wrapper.delete_vrrp_port(object_id='foo')
|
||||
neutron_wrapper.api_client.list_ports.assert_called_with(
|
||||
name='AKANDA:VRRP:foo'
|
||||
)
|
||||
self.assertFalse(neutron_wrapper.api_client.delete_port.called)
|
||||
|
||||
@mock.patch('akanda.rug.api.neutron.AkandaExtClientWrapper')
|
||||
def test_create_missing_gateway_port(self, client_wrapper):
|
||||
self.conf.retry_delay = 0
|
||||
|
||||
@@ -282,6 +282,9 @@ class VmManager(object):
|
||||
else:
|
||||
self.log.info('Destroying router')
|
||||
|
||||
worker_context.neutron.delete_vrrp_port(self.router_id)
|
||||
worker_context.neutron.delete_vrrp_port(self.router_id, label='MGT')
|
||||
|
||||
try:
|
||||
nova_client = worker_context.nova_client
|
||||
nova_client.destroy_instance(self.instance_info)
|
||||
|
||||
Reference in New Issue
Block a user