[L3] Delete DvrFipGatewayPortAgentBindings after no gw ports
This is the code behavior aligning for dvr related logical. The L3 dvr DB will remove all related FIP agent gateway port after there is no real use of it. But the DvrFipGatewayPortAgentBindings remain, it will cause the issue of new floating IP failed to bind. This patch adds the binding deleting action. Related-bug: #1883089 Change-Id: I62c29e172bc8705dade11d37bb347241ef8ad5f8
This commit is contained in:
parent
885cce39b7
commit
8dee0d9a4e
|
@ -371,6 +371,11 @@ class DVRResourceOperationHandler(object):
|
|||
# to clean up the fip namespace as it is no longer required.
|
||||
self.l3plugin.l3_rpc_notifier.delete_fipnamespace_for_ext_net(
|
||||
payload.context, network_id)
|
||||
# Delete the Floating IP agent gateway port
|
||||
# bindings on all hosts
|
||||
l3_obj.DvrFipGatewayPortAgentBinding.delete_objects(
|
||||
payload.context,
|
||||
network_id=network_id)
|
||||
|
||||
def _delete_fip_agent_port(self, context, network_id, host_id):
|
||||
try:
|
||||
|
|
|
@ -1344,3 +1344,27 @@ class L3DvrTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
|||
self.assertRaises(
|
||||
exceptions.BadRequest,
|
||||
self.mixin._get_assoc_data, self.ctx, mock.ANY, mock.Mock())
|
||||
|
||||
def test__delete_dvr_internal_ports(self):
|
||||
payload = mock.Mock()
|
||||
payload.context = mock.Mock()
|
||||
payload.latest_state = {'distributed': True}
|
||||
payload.metadata = {'new_network_id': 'fake-net-1',
|
||||
'network_id': 'fake-net-2'}
|
||||
plugin = mock.Mock()
|
||||
directory.add_plugin(plugin_constants.CORE, plugin)
|
||||
plugin.get_ports.return_value = []
|
||||
with mock.patch.object(self.mixin,
|
||||
'delete_floatingip_agent_gateway_port') as \
|
||||
del_port, \
|
||||
mock.patch.object(
|
||||
self.mixin.l3_rpc_notifier,
|
||||
'delete_fipnamespace_for_ext_net') as \
|
||||
del_fip_ns, \
|
||||
mock.patch.object(router_obj.DvrFipGatewayPortAgentBinding,
|
||||
"delete_objects") as del_binding:
|
||||
self.mixin._delete_dvr_internal_ports(
|
||||
None, None, resources.ROUTER_GATEWAY, payload)
|
||||
del_port.assert_called_once()
|
||||
del_fip_ns.assert_called_once()
|
||||
del_binding.assert_called_once()
|
||||
|
|
Loading…
Reference in New Issue