Fix full graph loadbalancer creation if jobboard is disabled

This patch fixes the creation of a full loadbalancer graph in case the
jobboard_enabled config value is False, when no "listeners" parameter was
passed to the get_create_load_balancer_flow function call: use kwargs as the
flow creation function parameters and handle "store" separately.

Story 2010335
Task 46462

Signed-off-by: Anton Kurbatov <Anton.Kurbatov@acronis.com>
Change-Id: Id328b27db1ec9c8e17bf18120259e41e75dab3b9
(cherry picked from commit 216cce39c9)
This commit is contained in:
Anton Kurbatov 2022-09-28 18:48:45 +00:00 committed by Sergey Kraynev
parent 8fa8d8f071
commit c662e42b84
3 changed files with 54 additions and 1 deletions

View File

@ -105,8 +105,9 @@ class ControllerWorker(object):
LOG.info("Taskflow job will execute flow %s with id %s",
func.__name__, job_id)
else:
store = kwargs.pop('store', None)
tf = self.tf_engine.taskflow_load(
func(*args), **kwargs)
func(*args, **kwargs), store=store)
with tf_logging.DynamicLoggingListener(tf, log=LOG):
tf.run()

View File

@ -652,6 +652,53 @@ class TestControllerWorker(base.TestCase):
constants.TOPOLOGY_ACTIVE_STANDBY, listeners=dict_listeners,
store=store)
@mock.patch('octavia.controller.worker.v2.flows.load_balancer_flows.'
'LoadBalancerFlows.get_create_load_balancer_flow')
@mock.patch('octavia.common.base_taskflow.BaseTaskFlowEngine.'
'taskflow_load')
def test_create_load_balancer_full_graph_jobboard_disabled(
self,
mock_base_taskflow_load,
mock_get_create_load_balancer_flow,
mock_api_get_session,
mock_dyn_log_listener,
mock_taskflow_load,
mock_pool_repo_get,
mock_member_repo_get,
mock_l7rule_repo_get,
mock_l7policy_repo_get,
mock_listener_repo_get,
mock_lb_repo_get,
mock_health_mon_repo_get,
mock_amp_repo_get):
self.conf.config(group="task_flow", jobboard_enabled=False)
listeners = [data_models.Listener(id='listener1'),
data_models.Listener(id='listener2')]
dict_listeners = [listener.to_dict() for listener in
provider_utils.db_listeners_to_provider_listeners(
listeners)]
lb = data_models.LoadBalancer(id=LB_ID, listeners=listeners,
topology=constants.TOPOLOGY_SINGLE)
mock_lb_repo_get.return_value = lb
store = {
constants.LOADBALANCER_ID: LB_ID,
'update_dict': {'topology': constants.TOPOLOGY_SINGLE},
constants.BUILD_TYPE_PRIORITY: constants.LB_CREATE_NORMAL_PRIORITY,
constants.FLAVOR: None,
constants.SERVER_GROUP_ID: None,
constants.AVAILABILITY_ZONE: None,
}
cw = controller_worker.ControllerWorker()
cw.create_load_balancer(_load_balancer_mock)
mock_get_create_load_balancer_flow.assert_called_with(
constants.TOPOLOGY_SINGLE, listeners=dict_listeners)
mock_base_taskflow_load.assert_called_with(
mock_get_create_load_balancer_flow.return_value, store=store)
def test_delete_load_balancer_without_cascade(self,
mock_api_get_session,
mock_dyn_log_listener,

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fix a bug when full graph of load balancer is created without
listeners if jobboard_enabled=False