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 logic for dns lookup. #2166

Merged
merged 8 commits into from
Jan 8, 2024
Merged
Changes from 5 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
14 changes: 7 additions & 7 deletions src/_nebari/stages/kubernetes_ingress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ def check_ingress_dns(stage_outputs: Dict[str, Dict[str, Any]], disable_prompt:
directory = "stages/04-kubernetes-ingress"

ip_or_name = stage_outputs[directory]["load_balancer_address"]["value"]
ip = socket.gethostbyname(ip_or_name["hostname"] or ip_or_name["ip"])
_, _, ips = socket.gethostbyname_ex(ip_or_name["hostname"] or ip_or_name["ip"])
domain_name = stage_outputs[directory]["domain"]

def _attempt_dns_lookup(
domain_name, ip, num_attempts=NUM_ATTEMPTS, timeout=TIMEOUT
domain_name, ips, num_attempts=NUM_ATTEMPTS, timeout=TIMEOUT
):
for i in range(num_attempts):
try:
resolved_ip = socket.gethostbyname(domain_name)
if resolved_ip == ip:
_, _, resolved_ips = socket.gethostbyname_ex(domain_name)
if set(resolved_ips) == set(ips):
pt247 marked this conversation as resolved.
Show resolved Hide resolved
print(
f"DNS configured domain={domain_name} matches ingress ip={ip}"
f"DNS configured domain={domain_name} matches ingress ips={ips}"
)
return True
else:
print(
f"Attempt {i+1} polling DNS domain={domain_name} does not match ip={ip} instead got {resolved_ip}"
f"Attempt {i+1} polling DNS domain={domain_name} does not match ip={ips} instead got {resolved_ips}"
)
except socket.gaierror:
print(
Expand All @@ -93,7 +93,7 @@ def _attempt_dns_lookup(
return False

attempt = 0
while not _attempt_dns_lookup(domain_name, ip):
while not _attempt_dns_lookup(domain_name, ips):
sleeptime = 60 * (2**attempt)
if not disable_prompt:
input(
Expand Down
Loading