Skip to content

Horizon Not Starting in IPv6 SingleStack OpenShift Cluster #478

@blackphantom39

Description

@blackphantom39

While trying to enable the deployment of Horizon in a Single Stack IPv6 cluster I came across the following error:

ALLOWED_HOSTS = [get_pod_ip(), "horizon-openstack.apps.lab._redacted_"]
File "/usr/lib/python3.9/site-packages/openstack_dashboard/local/local_settings.py", line 72, in get_pod_ip
s.connect(hostport)
OSError: [Errno 101] Network is unreachable

From what I can tell the IPv6 supported added in #315 only works within DualStack setups, but I am not able to verify this. The problem to me seems to stem from the attempt in the try catch block to use IPv4 first:

    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        s.connect(("{{ .horizonEndpointUrl }}", 80))
        return s.getsockname()[0]
    except socket.gaierror:
[...]

Ref

As there would not be any IPv4 Network available it would raise the aforementioned OSError and never actually attempt to connect via IPv6. My crude attempt for a fix was to add a config map that overwrites the file with the get_pod_ip() function changed to the following:

def get_pod_ip():
    import socket
    import errno

    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    hostport = ("{{ .horizonEndpointUrl }}", 443)
    try:
        s.connect(hostport)
        return s.getsockname()[0]

    except OSError as e:
        if e.errno == errno.ENETUNREACH:
            s.close()
            s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
            s.connect(hostport)
            return "[{}]".format(s.getsockname()[0])
        else:
            raise

    except socket.gaierror:
        s.close()
        s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
        s.connect(hostport)
        return "[{}]".format(s.getsockname()[0])
    finally:
        s.close()

However, this resulted in other problems, as I assume the kolla config running on startup tries to change the file. If the lack of an IPv4 address is the actual problem here and the "fix" /workaround is acceptable I would submit a PR accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions