Skip to content

enh: do not retry API requests when the server name cannot be resolved - #125

Merged
paulmueller merged 1 commit into
DCOR-dev:mainfrom
paulmueller-agent:no-retry-name-resolution
Nov 4, 2026
Merged

paulmueller merged 1 commit into
DCOR-dev:mainfrom
paulmueller-agent:no-retry-name-resolution

Conversation

@paulmueller-agent

Copy link
Copy Markdown
Contributor

Follow-up to #124: instead of only speeding up the test, stop retrying requests whose host name cannot be resolved.

Problem
retry_strategy in dcoraid/api/ckan_api.py treats a NameResolutionError like any other connection error, so every request to a wrong server name made 1 try + 3 retries with back-off. DCOR-Aid makes 8 such requests at startup/shutdown with a wrong server, so the main window took 45 s to open on Linux and 20 min on the Windows runners, where each failed lookup takes about 37 s. A real user with a mistyped server name would see the same freeze.

Change

  • RetryExceptNameResolution: a urllib3 Retry subclass whose increment raises MaxRetryError right away for NameResolutionError; everything else (connect/read retries, back-off) is unchanged. requests still raises a ConnectionError with "Failed to resolve" in the message.
  • New test test_api_no_retry_on_name_resolution_error (host name lookup is mocked and must happen exactly once).
  • CHANGELOG entry (may conflict with tests: let name resolution fail immediately in test_gui_start_with_bad_server #124's entry; whichever is merged second needs a trivial rebase).

Effect (local, Linux)

  • test_gui_start_with_bad_server: 45 s → 0.35 s
  • test_cli_fail_wrong_server_httperror: 90 s → 0.29 s (the CLI's own "Retrying ..." loop still runs)

With this, the mock added in #124 is no longer needed for speed, but it still keeps the test independent of DNS. Tell me if you'd rather drop #124.

ruff and flake8 pass; tests/test_api_base.py and the two tests above pass locally.

🤖 Generated with Claude Code

A failed name lookup is rarely transient, and on the Windows runners
every failed lookup took about 37 s. With 1 try plus 3 retries per
request, DCOR-Aid froze for minutes when started with a wrong server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 72.67%. Comparing base (82851e6) to head (5a9e6dc).

Files with missing lines Patch % Lines
dcoraid/api/ckan_api.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
- Coverage   72.72%   72.67%   -0.06%     
==========================================
  Files          72       72              
  Lines        6057     6063       +6     
==========================================
+ Hits         4405     4406       +1     
- Misses       1652     1657       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paulmueller
paulmueller merged commit 8bca8f9 into DCOR-dev:main Nov 4, 2026
4 of 5 checks passed
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.

2 participants