Skip to content

Conversation

@bshephar
Copy link
Contributor

@bshephar bshephar commented Aug 19, 2025

In cases where single-stack IPv6 is used, it's possible that an unhandled exception is raised since we first attempt to verify ipv4 connectivity and fail before checking ipv6. This change makes the get_pod_ip() function more robust by ensuring that both are checked before raising an error.

Fixes #478

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 19, 2025

Hi @bshephar. Thanks for your PR.

I'm waiting for a openstack-k8s-operators member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@bshephar
Copy link
Contributor Author

Tested like so:

>>> def get_pod_ip():
...     import socket
...
...     ipstacks = [socket.AF_INET, socket.AF_INET6]
...     last_error = None
...
...     host = "google.com"
...     port = 443
...
...     for ipstack in ipstacks:
...         try:
...             s = socket.socket(ipstack, socket.SOCK_DGRAM)
...             s.settimeout(2)
...             s.connect((host, port))
...             ip = s.getsockname()[0]
...             s.close()
...             return ip if ipstack == socket.AF_INET else f"[{ip}]"
...         except Exception as e:
...             last_error = e
...
...     raise RuntimeError(f"Could not determine pod IP: {last_error}")
...
>>> get_pod_ip()
'[2403:5817:3864:0:e0bd:373d:1b4e:1d5c]'

@bshephar
Copy link
Contributor Author

My bad:

++ /usr/bin/python3 /usr/bin/manage.py collectstatic --noinput --clear
Traceback (most recent call last):
  File "/usr/bin/manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 363, in execute
    settings.INSTALLED_APPS
  File "/usr/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/usr/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/openstack_dashboard/settings.py", line 245, in <module>
    from local.local_settings import *  # noqa: F403,H303
  File "/usr/lib/python3.9/site-packages/openstack_dashboard/local/local_settings.py", line 86, in <module>
    ALLOWED_HOSTS = [get_pod_ip(), "horizon.horizon-kuttl-tests.svc"]
  File "/usr/lib/python3.9/site-packages/openstack_dashboard/local/local_settings.py", line 71, in get_pod_ip
    port = 443 if true else 80
NameError: name 'true' is not defined

@bshephar bshephar force-pushed the robust-ip-checking branch from ee2e6ce to adff15f Compare August 21, 2025 00:06
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 21, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bshephar
Once this PR has been reviewed and has the lgtm label, please assign mcgonago for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bshephar
Copy link
Contributor Author

Alright, looks good now from a Kuttl test perspective. @deshipu @mcgonago Let me know if you have any concerns with the change here.

@bshephar bshephar force-pushed the robust-ip-checking branch 2 times, most recently from 022e5c7 to 7bf3b9c Compare September 4, 2025 11:11
@softwarefactory-project-zuul
Copy link

Build failed (check pipeline). Post recheck (without leading slash)
to rerun all jobs. Make sure the failure cause has been resolved before
you rerun jobs.

https://softwarefactory-project.io/zuul/t/rdoproject.org/buildset/6f10386c0b8d4d79952c45901c95f010

openstack-k8s-operators-content-provider TIMED_OUT in 30m 50s
⚠️ horizon-operator-kuttl SKIPPED Skipped due to failed job openstack-k8s-operators-content-provider (non-voting)

@bshephar
Copy link
Contributor Author

bshephar commented Sep 4, 2025

/test horizon-operator-build-deploy-kuttl

@bshephar
Copy link
Contributor Author

bshephar commented Sep 4, 2025

recheck

In cases where single-stack IPv6 is used, it's possible that
an unhandled exception is raised since we first attempt
to verify ipv4 connectivity and fail before checking ipv6.
This change makes the get_pod_ip() function more robust
by ensuring that both are checked before raising an error.

Fixes openstack-k8s-operators#478
Jira: https://issues.redhat.com/browse/OSPRH-19216
Signed-off-by: Brendan Shephard <[email protected]>
@stuggi stuggi requested review from deshipu and mcgonago October 6, 2025 06:58
@stuggi
Copy link
Contributor

stuggi commented Oct 29, 2025

@deshipu @mcgonago can you please review this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Horizon Not Starting in IPv6 SingleStack OpenShift Cluster

3 participants