Skip to content

fix: bound public IP lookup requests with a timeout - #202

Merged
njucjc merged 1 commit into
openyurtio:mainfrom
RaphaelFakhri:fix/public-ip-request-timeout
Nov 6, 2026
Merged

njucjc merged 1 commit into
openyurtio:mainfrom
RaphaelFakhri:fix/public-ip-request-timeout

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it

getFromAPI uses http.Get, so it runs on http.DefaultClient, which has no timeout. When a public IP API accepts the connection and then stalls, the call never returns. GetPublicIP never tries the next API, and the tunnel Handler blocks inside configGatewayPublicIP.

This PR sends the requests through an http.Client with a 10 second timeout. A stalled API now returns an error, and GetPublicIP falls through to the next URL in APIs.

The new TestGetFromAPIStalledServer test points getFromAPI at an httptest server that never responds. It checks that the call returns an error instead of hanging.

Which issue(s) this PR fixes

Fixes #201

Special notes for your reviewer

  • Without the change, the new test fails after its 30 second guard. With the change, it passes in about 10 seconds.
  • The change affects only the public IP lookup in pkg/utils/public_ip.go.

Does this PR introduce a user-facing change?

Public IP lookups time out after 10 seconds, so a stalled API no longer blocks the tunnel engine.

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.47%. Comparing base (17f1d19) to head (021e695).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
+ Coverage   46.42%   46.47%   +0.04%     
==========================================
  Files          39       39              
  Lines        4213     4213              
==========================================
+ Hits         1956     1958       +2     
+ Misses       2040     2039       -1     
+ Partials      217      216       -1     
Flag Coverage Δ
unittests 46.47% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@njucjc
njucjc merged commit 414fae1 into openyurtio:main Nov 6, 2026
11 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.

Public IP lookup can block the tunnel engine forever when an API stalls

2 participants