Skip to content

fix(utils): don't warn when network is unreachable in _get_ip - #9360

Open
fwh888 wants to merge 1 commit into
dask:mainfrom
fwh888:fix/offline-ip-warning
Open

fix(utils): don't warn when network is unreachable in _get_ip#9360
fwh888 wants to merge 1 commit into
dask:mainfrom
fwh888:fix/offline-ip-warning

Conversation

@fwh888

@fwh888 fwh888 commented Sep 5, 2026

Copy link
Copy Markdown

Summary

LocalCluster(processes=False) on a machine without external connectivity emits a spurious RuntimeWarning every time it starts:

RuntimeWarning: Couldn't detect a suitable IP address for reaching "8.8.8.8", defaulting to hostname: [Errno 101] Network is unreachable

The UDP probe in _get_ip raises OSError when the default probe host 8.8.8.8 is unreachable (offline machine). This is an expected, recoverable condition — the hostname_fallback() path already yields a usable local address.

Changes

In distributed/utils.py, _get_ip now silently downgrades to the hostname fallback for network-unreachable errors (ENETUNREACH, EHOSTUNREACH, ENETDOWN) instead of emitting a RuntimeWarning. Genuine socket errors (e.g. EACCES) still warn as before.

Tests

Added unit tests in tests/test_utils.py:

  • test_get_ip_silent_when_network_unreachable — asserts no warning is raised on ENETUNREACH
  • test_get_ip_warns_for_other_socket_errors — asserts EACCES still warns
  • test_get_ip_returns_local_address — normal probe path unchanged

All updated tests pass; ruff and pre-commit clean on touched files.

Fixes #8559

LocalCluster(processes=False) on a machine without external connectivity
emits a spurious RuntimeWarning ("Couldn't detect a suitable IP address
for reaching '8.8.8.8'...") every time it starts.

ENETUNREACH / EHOSTUNREACH / ENETDOWN are expected on offline machines;
the hostname fallback already yields a usable local address, so only
warn for genuine socket errors (e.g. EACCES), not for ordinary offline
use.

Adds unit tests covering:
- silent downgrade on ENETUNREACH (no RuntimeWarning)
- preserved warning for other OSError (EACCES)
- normal UDP probe returns the local address without warning
@fwh888
fwh888 force-pushed the fix/offline-ip-warning branch from 9fd966d to 92c89ad Compare September 5, 2026 01:16
@fwh888

fwh888 commented Sep 5, 2026

Copy link
Copy Markdown
Author

Hi maintainers 👋 — a quick note on the current CI status to make review easier:

Green (relevant to this PR):

  • pre-commit hooks ✅ (ruff format/lint + all hooks)
  • Build (and upload)
  • docs/readthedocs.org:distributed
  • 35+ test-matrix jobs ✅ (arm/mac/mindeps + several py versions, both ci partitions)

The 3 failures are unrelated to this change:

  • nightly test (×2) fails at pixi install (dependency resolution) — the same failure exists on main 16c1bdc/82137211.
  • ubuntu-latest py310 test-noqueue not ci1 fails only on test_shuffle.py::test_restarting_during_transfer_raises_killed_worker — a shuffle-transfer timing/flakiness case, with no relation to get_ip or the error-path change here.

The change itself is narrow: _get_ip now silently falls back to the hostname when the UDP probe fails with ENETUNREACH/EHOSTUNREACH/ENETDOWN, with 3 dedicated unit tests (silent downgrade, preserved warning for other OSError, unchanged normal path).

Happy to rerun or adjust anything. Thanks!

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

    40 files  ± 0      40 suites  ±0   14h 43m 21s ⏱️ + 24m 23s
 4 163 tests + 3   3 983 ✅ + 3    179 💤 ±0  1 ❌ ±0 
81 022 runs  +60  76 779 ✅ +60  4 242 💤 ±0  1 ❌ ±0 

For more details on these failures, see this check.

Results for commit 92c89ad. ± Comparison against base commit dc182bd.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning when opening LocalCluster if not having network access

1 participant