From a460698cd933112529d1eae27d483da6b3035eff Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Mon, 20 Mar 2023 15:09:52 +0100 Subject: [PATCH] Fix octavia to accept [ipv6]:port A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This patch fixes octavia to be able parse and use this format. Story 2010655 Task 47687 Change-Id: Ib1e00a0b45776cfab80b9effb2690e12fea63e78 --- .../backends/health_daemon/health_sender.py | 2 ++ .../health_daemon/test_health_sender.py | 18 ++++++++++++++++++ ...-enclosed-in-brackets-c1cfc4717465ba09.yaml | 6 ++++++ 3 files changed, 26 insertions(+) create mode 100644 releasenotes/notes/fix-ipv6-address-enclosed-in-brackets-c1cfc4717465ba09.yaml 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``.