Add support for different loadbalancer algorithms
Change-Id: Ide0c7d2480469bca711039ee5b7d12f92078a8b6
This commit is contained in:
parent
a8fe3afa69
commit
14103941dc
@ -60,6 +60,7 @@ VAR_RUN_PATH=/usr/local/var/run
|
||||
# KURYR_K8S_OCTAVIA_MEMBER_MODE=L2
|
||||
# KURYR_K8S_OCTAVIA_SG_MODE=create
|
||||
# KURYR_ENFORCE_SG_RULES=False
|
||||
# KURYR_LB_ALGORITHM=SOURCE_IP_PORT
|
||||
|
||||
|
||||
# Octavia LBaaSv2
|
||||
|
@ -471,6 +471,7 @@ function configure_neutron_defaults {
|
||||
iniset "$KURYR_CONFIG" octavia_defaults member_mode "$KURYR_K8S_OCTAVIA_MEMBER_MODE"
|
||||
iniset "$KURYR_CONFIG" octavia_defaults sg_mode "$KURYR_K8S_OCTAVIA_SG_MODE"
|
||||
iniset "$KURYR_CONFIG" octavia_defaults enforce_sg_rules "$KURYR_ENFORCE_SG_RULES"
|
||||
iniset "$KURYR_CONFIG" octavia_defaults lb_algorithm "$KURYR_LB_ALGORITHM"
|
||||
# Octavia takes a very long time to start the LB in the gate. We need
|
||||
# to tweak the timeout for the LB creation. Let's be generous and give
|
||||
# it up to 20 minutes.
|
||||
|
@ -58,6 +58,7 @@ OPENSHIFT_CNI_BINARY_URL=${OPENSHIFT_CNI_BINARY_URL:-https://github.com/containe
|
||||
KURYR_K8S_OCTAVIA_MEMBER_MODE=${KURYR_K8S_OCTAVIA_MEMBER_MODE:-L3}
|
||||
KURYR_K8S_OCTAVIA_SG_MODE=${KURYR_K8S_OCTAVIA_SG_MODE:-update}
|
||||
KURYR_ENFORCE_SG_RULES=${KURYR_ENFORCE_SG_RULES:-True}
|
||||
KURYR_LB_ALGORITHM=${KURYR_LB_ALGORITHM:-ROUND_ROBIN}
|
||||
|
||||
# Kuryr_ovs_baremetal
|
||||
KURYR_CONFIGURE_BAREMETAL_KUBELET_IFACE=${KURYR_CONFIGURE_BAREMETAL_KUBELET_IFACE:-True}
|
||||
|
@ -242,6 +242,11 @@ octavia_defaults = [
|
||||
"in case the LB does not maintain the source IP "
|
||||
"of the caller resource"),
|
||||
default=True),
|
||||
cfg.StrOpt('lb_algorithm',
|
||||
help=_("The load-balancer algoritm that distributed traffic "
|
||||
"to the pool members. The options are: ROUND_ROBIN, "
|
||||
"LEAST_CONNECTIONS, SOURCE_IP and SOURCE_IP_PORT."),
|
||||
default='ROUND_ROBIN'),
|
||||
]
|
||||
|
||||
cache_defaults = [
|
||||
|
@ -621,7 +621,7 @@ class LBaaSv2Driver(base.LBaaSDriver):
|
||||
|
||||
def _create_pool(self, pool):
|
||||
# TODO(ivc): make lb_algorithm configurable
|
||||
lb_algorithm = 'ROUND_ROBIN'
|
||||
lb_algorithm = CONF.octavia_defaults.lb_algorithm
|
||||
request = {
|
||||
'name': pool.name,
|
||||
'project_id': pool.project_id,
|
||||
|
@ -530,6 +530,36 @@ class TestLBaaSv2Driver(test_base.TestCase):
|
||||
getattr(ret, attr))
|
||||
self.assertEqual(pool_id, ret.id)
|
||||
|
||||
def test_create_pool_with_different_lb_algorithm(self):
|
||||
cls = d_lbaasv2.LBaaSv2Driver
|
||||
m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver)
|
||||
lb_algorithm = 'SOURCE_IP_PORT'
|
||||
pool = obj_lbaas.LBaaSPool(
|
||||
name='TEST_NAME', project_id='TEST_PROJECT', protocol='TCP',
|
||||
listener_id='A57B7771-6050-4CA8-A63C-443493EC98AB',
|
||||
loadbalancer_id='00EE9E11-91C2-41CF-8FD4-7970579E5C4C')
|
||||
pool_id = 'D4F35594-27EB-4F4C-930C-31DD40F53B77'
|
||||
req = {
|
||||
'name': pool.name,
|
||||
'project_id': pool.project_id,
|
||||
'listener_id': pool.listener_id,
|
||||
'loadbalancer_id': pool.loadbalancer_id,
|
||||
'protocol': pool.protocol,
|
||||
'lb_algorithm': lb_algorithm}
|
||||
resp = o_pool.Pool(id=pool_id)
|
||||
m_driver._post_lb_resource.return_value = resp
|
||||
CONF.set_override('lb_algorithm', lb_algorithm,
|
||||
group='octavia_defaults')
|
||||
self.addCleanup(CONF.clear_override, 'lb_algorithm',
|
||||
group='octavia_defaults')
|
||||
|
||||
ret = cls._create_pool(m_driver, pool)
|
||||
m_driver._post_lb_resource.assert_called_once_with(o_pool.Pool, req)
|
||||
for attr in pool.obj_fields:
|
||||
self.assertEqual(getattr(pool, attr),
|
||||
getattr(ret, attr))
|
||||
self.assertEqual(pool_id, ret.id)
|
||||
|
||||
def test_create_pool_conflict(self):
|
||||
cls = d_lbaasv2.LBaaSv2Driver
|
||||
m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver)
|
||||
|
Loading…
Reference in New Issue
Block a user