fix(lan): warn when auto-detected endpoint IP is in Docker/WSL2 172.16/12 range
Nodes running inside WSL2 or Docker have a virtual network interface whose IP (172.16-31.x.x) is not reachable from physical machines on the LAN. The UDP socket probe for outbound IP returns this virtual IP, which gets registered with the tracker — causing downstream pipeline hops to time out with "urlopen error timed out". _warn_virtual_network_ip() now prints a clear multi-line warning at startup when the auto-detected advertise IP falls in 172.16.0.0/12, including the fix: --advertise-host <LAN-ip>. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -179,6 +179,35 @@ def _start_heartbeat(
|
||||
return t
|
||||
|
||||
|
||||
def _warn_virtual_network_ip(ip: str | None) -> None:
|
||||
"""Print a warning when the auto-detected advertise IP is in a known virtual-network range.
|
||||
|
||||
172.16.0.0/12 is used by Docker, WSL2, and most hypervisors. Nodes behind these
|
||||
adapters are NOT directly reachable from other physical machines on the LAN, so
|
||||
cross-host pipeline hops will time out. The user must pass --advertise-host with
|
||||
their actual LAN IP (e.g. 192.168.x.x) to fix this.
|
||||
"""
|
||||
if ip is None:
|
||||
return
|
||||
try:
|
||||
parts = [int(p) for p in ip.split(".")]
|
||||
if len(parts) != 4:
|
||||
return
|
||||
a, b = parts[0], parts[1]
|
||||
# 172.16.0.0/12 → 172.16–31.x.x
|
||||
if a == 172 and 16 <= b <= 31:
|
||||
print(
|
||||
f"\n WARNING: auto-detected endpoint IP {ip} is in 172.16.0.0/12.\n"
|
||||
f" This range is used by Docker, WSL2, and virtual machines and is\n"
|
||||
f" NOT reachable from other physical machines on your LAN.\n"
|
||||
f" Cross-host pipeline hops WILL time out.\n"
|
||||
f" Fix: pass --advertise-host <your-LAN-ip> (e.g. 192.168.x.x).\n",
|
||||
flush=True,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def run_startup(
|
||||
tracker_url: str,
|
||||
port: int = 0,
|
||||
@@ -224,6 +253,8 @@ def run_startup(
|
||||
except Exception:
|
||||
advertise_host = socket.getfqdn()
|
||||
|
||||
_warn_virtual_network_ip(advertise_host)
|
||||
|
||||
print("Detecting hardware...", flush=True)
|
||||
hw = detect_hardware()
|
||||
device: str = hw["device"]
|
||||
|
||||
Reference in New Issue
Block a user