Refactors LB delete flow and removes listener delete
This refactors the method generating the lb delete flow and removes redundant code between cascade and the normal delete. It also removed the listener delete from the non-cascade flow thus speeding up the deletion. Change-Id: I6133e9b5f1c4c440a56bf75a1e3369424971f33a
This commit is contained in:
parent
c6eb595796
commit
6a6e0d243b
@ -227,32 +227,7 @@ class LoadBalancerFlows(object):
|
||||
|
||||
:returns: The flow for deleting a load balancer
|
||||
"""
|
||||
(listeners_delete, store) = self._get_delete_listeners_flow(lb)
|
||||
|
||||
delete_LB_flow = linear_flow.Flow(constants.DELETE_LOADBALANCER_FLOW)
|
||||
delete_LB_flow.add(lifecycle_tasks.LoadBalancerToErrorOnRevertTask(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(compute_tasks.NovaServerGroupDelete(
|
||||
requires=constants.SERVER_GROUP_ID))
|
||||
delete_LB_flow.add(database_tasks.MarkLBAmphoraeHealthBusy(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(listeners_delete)
|
||||
delete_LB_flow.add(network_tasks.UnplugVIP(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(network_tasks.DeallocateVIP(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(compute_tasks.DeleteAmphoraeOnLoadBalancer(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(database_tasks.MarkLBAmphoraeDeletedInDB(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(database_tasks.DisableLBAmphoraeHealthMonitoring(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(database_tasks.MarkLBDeletedInDB(
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(database_tasks.DecrementLoadBalancerQuota(
|
||||
requires=constants.LOADBALANCER))
|
||||
|
||||
return (delete_LB_flow, store)
|
||||
return self._get_delete_load_balancer_flow(lb, False)
|
||||
|
||||
def _get_delete_pools_flow(self, lb):
|
||||
"""Sets up an internal delete flow
|
||||
@ -273,16 +248,8 @@ class LoadBalancerFlows(object):
|
||||
pool_name))
|
||||
return (pools_delete_flow, store)
|
||||
|
||||
def get_cascade_delete_load_balancer_flow(self, lb):
|
||||
"""Creates a flow to delete a load balancer.
|
||||
|
||||
:returns: The flow for deleting a load balancer
|
||||
"""
|
||||
|
||||
(listeners_delete, store) = self._get_delete_listeners_flow(lb)
|
||||
(pools_delete, pool_store) = self._get_delete_pools_flow(lb)
|
||||
store.update(pool_store)
|
||||
|
||||
def _get_delete_load_balancer_flow(self, lb, cascade):
|
||||
store = {}
|
||||
delete_LB_flow = linear_flow.Flow(constants.DELETE_LOADBALANCER_FLOW)
|
||||
delete_LB_flow.add(lifecycle_tasks.LoadBalancerToErrorOnRevertTask(
|
||||
requires=constants.LOADBALANCER))
|
||||
@ -290,6 +257,10 @@ class LoadBalancerFlows(object):
|
||||
requires=constants.SERVER_GROUP_ID))
|
||||
delete_LB_flow.add(database_tasks.MarkLBAmphoraeHealthBusy(
|
||||
requires=constants.LOADBALANCER))
|
||||
if cascade:
|
||||
(listeners_delete, store) = self._get_delete_listeners_flow(lb)
|
||||
(pools_delete, pool_store) = self._get_delete_pools_flow(lb)
|
||||
store.update(pool_store)
|
||||
delete_LB_flow.add(pools_delete)
|
||||
delete_LB_flow.add(listeners_delete)
|
||||
delete_LB_flow.add(network_tasks.UnplugVIP(
|
||||
@ -306,9 +277,15 @@ class LoadBalancerFlows(object):
|
||||
requires=constants.LOADBALANCER))
|
||||
delete_LB_flow.add(database_tasks.DecrementLoadBalancerQuota(
|
||||
requires=constants.LOADBALANCER))
|
||||
|
||||
return (delete_LB_flow, store)
|
||||
|
||||
def get_cascade_delete_load_balancer_flow(self, lb):
|
||||
"""Creates a flow to delete a load balancer.
|
||||
|
||||
:returns: The flow for deleting a load balancer
|
||||
"""
|
||||
return self._get_delete_load_balancer_flow(lb, True)
|
||||
|
||||
def get_new_LB_networking_subflow(self):
|
||||
"""Create a sub-flow to setup networking.
|
||||
|
||||
|
@ -90,13 +90,12 @@ class TestLoadBalancerFlows(base.TestCase):
|
||||
lb_flow, store = self.LBFlow.get_delete_load_balancer_flow(lb_mock)
|
||||
|
||||
self.assertIsInstance(lb_flow, flow.Flow)
|
||||
self.assertEqual({'listener_123': listener_mock}, store)
|
||||
|
||||
self.assertIn(constants.LOADBALANCER, lb_flow.requires)
|
||||
self.assertIn(constants.SERVER_GROUP_ID, lb_flow.requires)
|
||||
|
||||
self.assertEqual(0, len(lb_flow.provides))
|
||||
self.assertEqual(3, len(lb_flow.requires))
|
||||
self.assertEqual(2, len(lb_flow.requires))
|
||||
|
||||
def test_get_delete_load_balancer_flow_cascade(self, mock_get_net_driver):
|
||||
lb_mock = mock.Mock()
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Removes unnecessary listener delete from non-cascade delete load balancer
|
||||
flow thus speeding up the loadbalancer delete.
|
Loading…
Reference in New Issue
Block a user