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
This commit is contained in:
Michal Arbet 2023-03-20 15:09:52 +01:00
parent 764cbf014f
commit a460698cd9
3 changed files with 26 additions and 0 deletions

View File

@ -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)

View File

@ -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",

View File

@ -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``.