Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix find-resolv-conf.py from breaking with scoped IPv6 addresses #4328

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/find-resolv-conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,17 @@ def safe_is_non_loopback_address(address: str):
try:
return not ipaddress.ip_address(address).is_loopback
except ValueError:
return False
# NOTE(neoaggelos): https://github.com/canonical/microk8s/issues/4327
# Python 3.8 fails with scoped IPv6 address, e.g. "fe80::5054:ff:fe00:b61d%2"
# Try to remove the scope suffix, and accept if value is an IPv6 address
if "%" not in address:
return False

try:
ip = ipaddress.ip_address(address[: address.find("%")])
return ip.version == 6 and not ip.is_loopback
except (ValueError, IndexError):
return False


def find_resolv_conf_with_non_loopback_address(resolv_confs: list):
Expand Down
Loading