diff --git a/octavia/amphorae/backends/health_daemon/health_sender.py b/octavia/amphorae/backends/health_daemon/health_sender.py index e720569687..5608d57016 100644 --- a/octavia/amphorae/backends/health_daemon/health_sender.py +++ b/octavia/amphorae/backends/health_daemon/health_sender.py @@ -70,6 +70,8 @@ class UDPStatusSender(object): for ipport in CONF.health_manager.controller_ip_port_list: try: ip, port = ipport.rsplit(':', 1) + if ip and ip[0] == '[' and ip[-1] == ']': + ip = ip[1:-1] except ValueError: LOG.error("Invalid ip and port '%s' in health_manager " "controller_ip_port_list", ipport) diff --git a/octavia/tests/unit/amphorae/backends/health_daemon/test_health_sender.py b/octavia/tests/unit/amphorae/backends/health_daemon/test_health_sender.py index 3813922a2e..aa732b5181 100644 --- a/octavia/tests/unit/amphorae/backends/health_daemon/test_health_sender.py +++ b/octavia/tests/unit/amphorae/backends/health_daemon/test_health_sender.py @@ -93,6 +93,24 @@ class TestHealthSender(base.TestCase): sendto_mock.reset_mock() + # Test IPv6 path enclosed within square brackets ("[" and "]"). + self.conf.config(group="health_manager", + controller_ip_port_list=['[2001:0db8::f00d]:80']) + mock_getaddrinfo.return_value = [(socket.AF_INET6, + socket.SOCK_DGRAM, + socket.IPPROTO_UDP, + '', + ('2001:db8::f00d', 80, 0, 0))] + + sender = health_sender.UDPStatusSender() + + sender.dosend(SAMPLE_MSG) + + sendto_mock.assert_called_once_with(SAMPLE_MSG_BIN, + ('2001:db8::f00d', 80, 0, 0)) + + sendto_mock.reset_mock() + # Test IPv6 link-local address path self.conf.config( group="health_manager", diff --git a/releasenotes/notes/fix-ipv6-address-enclosed-in-brackets-c1cfc4717465ba09.yaml b/releasenotes/notes/fix-ipv6-address-enclosed-in-brackets-c1cfc4717465ba09.yaml new file mode 100644 index 0000000000..2d731ab3e2 --- /dev/null +++ b/releasenotes/notes/fix-ipv6-address-enclosed-in-brackets-c1cfc4717465ba09.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fix a bug that prevented the operating_status of a health-monitor to be + set to ONLINE when ipv6 addresses were enclosed within square brackets + in ``controller_ip_port_list``.