Add support for monitor_{address,port} in UDP members
UDP members didn't support monitor_address and monitor_port parameters. Setting those values didn't have any effects. This commit enables the support of both parameters. Story: 2005775 Task: 33492 Change-Id: Idaacfa60a1909d3f5e0f94371a405c8ce8ae9efa
This commit is contained in:
parent
37799137a3
commit
65e132a734
@ -174,7 +174,9 @@ class LvsJinjaTemplater(object):
|
|||||||
'address': member.ip_address,
|
'address': member.ip_address,
|
||||||
'protocol_port': member.protocol_port,
|
'protocol_port': member.protocol_port,
|
||||||
'weight': member.weight,
|
'weight': member.weight,
|
||||||
'enabled': member.enabled
|
'enabled': member.enabled,
|
||||||
|
'monitor_address': member.monitor_address,
|
||||||
|
'monitor_port': member.monitor_port
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_default_lvs_check_script_path(self):
|
def _get_default_lvs_check_script_path(self):
|
||||||
|
@ -19,7 +19,7 @@ lb_algo {{ pool.lb_algorithm }}
|
|||||||
{%- endmacro -%}
|
{%- endmacro -%}
|
||||||
|
|
||||||
{% macro misc_path_macro(member, health_monitor) -%}
|
{% macro misc_path_macro(member, health_monitor) -%}
|
||||||
misc_path "{{ health_monitor.check_script_path }} {{ member.address }} {{ member.protocol_port }}"
|
misc_path "{{ health_monitor.check_script_path }} {{ member.monitor_address|default(member.address, true) }} {{ member.monitor_port|default(member.protocol_port, true) }}"
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
{%- macro misc_check_macro(pool, member, health_monitor) -%}
|
{%- macro misc_check_macro(pool, member, health_monitor) -%}
|
||||||
|
@ -179,6 +179,54 @@ class TestLvsCfg(base.TestCase):
|
|||||||
connection_limit=98))
|
connection_limit=98))
|
||||||
self.assertEqual(exp, rendered_obj)
|
self.assertEqual(exp, rendered_obj)
|
||||||
|
|
||||||
|
def test_render_template_udp_with_health_monitor_ip_port(self):
|
||||||
|
exp = ("# Configuration for Loadbalancer sample_loadbalancer_id_1\n"
|
||||||
|
"# Configuration for Listener sample_listener_id_1\n\n"
|
||||||
|
"net_namespace amphora-haproxy\n\n"
|
||||||
|
"virtual_server 10.0.0.2 80 {\n"
|
||||||
|
" lb_algo rr\n"
|
||||||
|
" lb_kind NAT\n"
|
||||||
|
" protocol UDP\n"
|
||||||
|
" delay_loop 30\n"
|
||||||
|
" delay_before_retry 31\n"
|
||||||
|
" retry 3\n\n\n"
|
||||||
|
" # Configuration for Pool sample_pool_id_1\n"
|
||||||
|
" # Configuration for HealthMonitor sample_monitor_id_1\n"
|
||||||
|
" # Configuration for Member sample_member_id_1\n"
|
||||||
|
" real_server 10.0.0.99 82 {\n"
|
||||||
|
" weight 13\n"
|
||||||
|
" uthreshold 98\n"
|
||||||
|
" delay_before_retry 31\n"
|
||||||
|
" retry 3\n"
|
||||||
|
" MISC_CHECK {\n"
|
||||||
|
" misc_path \"/var/lib/octavia/lvs/check/"
|
||||||
|
"udp_check.sh 192.168.1.1 9000\"\n"
|
||||||
|
" misc_timeout 30\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n\n"
|
||||||
|
" # Configuration for Member sample_member_id_2\n"
|
||||||
|
" real_server 10.0.0.98 82 {\n"
|
||||||
|
" weight 13\n"
|
||||||
|
" uthreshold 98\n"
|
||||||
|
" delay_before_retry 31\n"
|
||||||
|
" retry 3\n"
|
||||||
|
" MISC_CHECK {\n"
|
||||||
|
" misc_path \"/var/lib/octavia/lvs/check/"
|
||||||
|
"udp_check.sh 192.168.1.1 9000\"\n"
|
||||||
|
" misc_timeout 30\n"
|
||||||
|
" }\n"
|
||||||
|
" }\n\n"
|
||||||
|
"}\n\n")
|
||||||
|
|
||||||
|
rendered_obj = self.udp_jinja_cfg.render_loadbalancer_obj(
|
||||||
|
sample_configs_combined.sample_listener_tuple(
|
||||||
|
proto=constants.PROTOCOL_UDP,
|
||||||
|
monitor_ip_port=True,
|
||||||
|
monitor_proto=constants.HEALTH_MONITOR_UDP_CONNECT,
|
||||||
|
persistence=False,
|
||||||
|
connection_limit=98))
|
||||||
|
self.assertEqual(exp, rendered_obj)
|
||||||
|
|
||||||
def test_render_template_udp_no_other_resources(self):
|
def test_render_template_udp_no_other_resources(self):
|
||||||
exp = ("# Configuration for Loadbalancer sample_loadbalancer_id_1\n"
|
exp = ("# Configuration for Loadbalancer sample_loadbalancer_id_1\n"
|
||||||
"# Configuration for Listener sample_listener_id_1\n\n"
|
"# Configuration for Listener sample_listener_id_1\n\n"
|
||||||
@ -216,6 +264,14 @@ class TestLvsCfg(base.TestCase):
|
|||||||
ret = self.udp_jinja_cfg._transform_member(in_member)
|
ret = self.udp_jinja_cfg._transform_member(in_member)
|
||||||
self.assertEqual(sample_configs_combined.RET_UDP_MEMBER, ret)
|
self.assertEqual(sample_configs_combined.RET_UDP_MEMBER, ret)
|
||||||
|
|
||||||
|
in_member = sample_configs_combined.sample_member_tuple(
|
||||||
|
'member_id_1',
|
||||||
|
'192.0.2.10',
|
||||||
|
monitor_ip_port=True)
|
||||||
|
ret = self.udp_jinja_cfg._transform_member(in_member)
|
||||||
|
self.assertEqual(
|
||||||
|
sample_configs_combined.RET_UDP_MEMBER_MONITOR_IP_PORT, ret)
|
||||||
|
|
||||||
def test_udp_transform_pool(self):
|
def test_udp_transform_pool(self):
|
||||||
in_pool = sample_configs_combined.sample_pool_tuple(
|
in_pool = sample_configs_combined.sample_pool_tuple(
|
||||||
proto=constants.PROTOCOL_UDP,
|
proto=constants.PROTOCOL_UDP,
|
||||||
|
@ -430,7 +430,19 @@ RET_UDP_MEMBER = {
|
|||||||
'address': '192.0.2.10',
|
'address': '192.0.2.10',
|
||||||
'protocol_port': 82,
|
'protocol_port': 82,
|
||||||
'weight': 13,
|
'weight': 13,
|
||||||
'enabled': True
|
'enabled': True,
|
||||||
|
'monitor_address': None,
|
||||||
|
'monitor_port': None
|
||||||
|
}
|
||||||
|
|
||||||
|
RET_UDP_MEMBER_MONITOR_IP_PORT = {
|
||||||
|
'id': 'member_id_1',
|
||||||
|
'address': '192.0.2.10',
|
||||||
|
'protocol_port': 82,
|
||||||
|
'weight': 13,
|
||||||
|
'enabled': True,
|
||||||
|
'monitor_address': '192.168.1.1',
|
||||||
|
'monitor_port': 9000
|
||||||
}
|
}
|
||||||
|
|
||||||
UDP_MEMBER_1 = {
|
UDP_MEMBER_1 = {
|
||||||
@ -438,7 +450,9 @@ UDP_MEMBER_1 = {
|
|||||||
'address': '10.0.0.99',
|
'address': '10.0.0.99',
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'protocol_port': 82,
|
'protocol_port': 82,
|
||||||
'weight': 13
|
'weight': 13,
|
||||||
|
'monitor_address': None,
|
||||||
|
'monitor_port': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
UDP_MEMBER_2 = {
|
UDP_MEMBER_2 = {
|
||||||
@ -446,7 +460,9 @@ UDP_MEMBER_2 = {
|
|||||||
'address': '10.0.0.98',
|
'address': '10.0.0.98',
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'protocol_port': 82,
|
'protocol_port': 82,
|
||||||
'weight': 13
|
'weight': 13,
|
||||||
|
'monitor_address': None,
|
||||||
|
'monitor_port': None
|
||||||
}
|
}
|
||||||
|
|
||||||
RET_UDP_POOL = {
|
RET_UDP_POOL = {
|
||||||
|
@ -429,7 +429,19 @@ RET_UDP_MEMBER = {
|
|||||||
'address': '192.0.2.10',
|
'address': '192.0.2.10',
|
||||||
'protocol_port': 82,
|
'protocol_port': 82,
|
||||||
'weight': 13,
|
'weight': 13,
|
||||||
'enabled': True
|
'enabled': True,
|
||||||
|
'monitor_address': None,
|
||||||
|
'monitor_port': None
|
||||||
|
}
|
||||||
|
|
||||||
|
RET_UDP_MEMBER_MONITOR_IP_PORT = {
|
||||||
|
'id': 'member_id_1',
|
||||||
|
'address': '192.0.2.10',
|
||||||
|
'protocol_port': 82,
|
||||||
|
'weight': 13,
|
||||||
|
'enabled': True,
|
||||||
|
'monitor_address': '192.168.1.1',
|
||||||
|
'monitor_port': 9000
|
||||||
}
|
}
|
||||||
|
|
||||||
UDP_MEMBER_1 = {
|
UDP_MEMBER_1 = {
|
||||||
@ -437,7 +449,9 @@ UDP_MEMBER_1 = {
|
|||||||
'address': '10.0.0.99',
|
'address': '10.0.0.99',
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'protocol_port': 82,
|
'protocol_port': 82,
|
||||||
'weight': 13
|
'weight': 13,
|
||||||
|
'monitor_address': None,
|
||||||
|
'monitor_port': None
|
||||||
}
|
}
|
||||||
|
|
||||||
UDP_MEMBER_2 = {
|
UDP_MEMBER_2 = {
|
||||||
@ -445,7 +459,9 @@ UDP_MEMBER_2 = {
|
|||||||
'address': '10.0.0.98',
|
'address': '10.0.0.98',
|
||||||
'enabled': True,
|
'enabled': True,
|
||||||
'protocol_port': 82,
|
'protocol_port': 82,
|
||||||
'weight': 13
|
'weight': 13,
|
||||||
|
'monitor_address': None,
|
||||||
|
'monitor_port': None
|
||||||
}
|
}
|
||||||
|
|
||||||
RET_UDP_POOL = {
|
RET_UDP_POOL = {
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Add support for monitor_address and monitor_port attributes in UDP members.
|
||||||
|
Previously, monitor_address and monitor_port were ignored and address and
|
||||||
|
protocol_port attributes were used as monitoring address and port.
|
Loading…
Reference in New Issue
Block a user