Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@anderbubble
Copy link
Collaborator

@anderbubble anderbubble commented Sep 9, 2025

Description of the Pull Request (PR):

In updateSystem(), Webclient.Get() returns an HTTP response, but never calls resp.Body.Close(). When using --once option, the process exits quickly after the HTTP request, but the underlying TCP connection may not be properly closed. This leaves the local port in a TIME_WAIT state, causing subsequent runs to fail with "address already in use."

In addition, connections in the pool were not being properly cleaned up on exit, and the connection was not told it was ok to re-use a recently-used port.

This fixes or addresses the following GitHub issues:

Reviewer checklist

The reviewer checks the following items before merging the PR.

  • The PR is based on the appropriate branch (typically main)
  • All commits are "Signed off" (e.g., using git commit --signoff) in agreement to the DCO
  • The CHANGELOG has been updated, if necessary, and under the correct release heading
  • The userdocs have been updated, if necessary
  • The submitter is listed in the contributors file
  • The test suite has been updated, if necessary

@anderbubble anderbubble added this to the v4.6.5 milestone Sep 9, 2025
@anderbubble anderbubble self-assigned this Sep 9, 2025
@anderbubble anderbubble modified the milestones: v4.6.5, v4.6.4 Sep 9, 2025
Copilot

This comment was marked as outdated.

@anderbubble anderbubble modified the milestones: v4.6.4, v4.6.5 Sep 9, 2025
@anderbubble anderbubble marked this pull request as draft September 9, 2025 23:28
@anderbubble
Copy link
Collaborator Author

Well, this doesn't appear to have fixed it yet.

@anderbubble anderbubble force-pushed the 2009-wwclient-once-address-already-in-use branch from 6057e96 to 6c66f37 Compare September 9, 2025 23:35
@anderbubble anderbubble changed the title Fix "address already in use" after wwclient --once Fix "address already in use" from wwclient when secure=true Sep 9, 2025
@anderbubble anderbubble force-pushed the 2009-wwclient-once-address-already-in-use branch 4 times, most recently from 686bf3e to 0b50a52 Compare September 10, 2025 00:08
@anderbubble anderbubble requested a review from Copilot September 10, 2025 00:17
Copilot

This comment was marked as outdated.

@anderbubble anderbubble force-pushed the 2009-wwclient-once-address-already-in-use branch 2 times, most recently from 413d58a to 86c8499 Compare September 10, 2025 00:19
@anderbubble anderbubble requested a review from Copilot September 10, 2025 00:20
Copilot

This comment was marked as outdated.

@anderbubble anderbubble force-pushed the 2009-wwclient-once-address-already-in-use branch 2 times, most recently from 46cea9d to b768049 Compare September 10, 2025 01:46
@anderbubble anderbubble requested a review from Copilot September 10, 2025 01:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes "address already in use" errors that occur when running wwclient with the --once option and secure=true. The issue was caused by HTTP response bodies not being properly closed and idle connections not being cleaned up on exit, leaving local ports in TIME_WAIT state.

  • Added defer resp.Body.Close() to properly close HTTP response bodies
  • Added SO_REUSEADDR socket option to allow immediate port reuse
  • Added connection cleanup in the cleanUp() function to close idle connections on exit

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/app/wwclient/root.go Adds socket options for port reuse, response body cleanup, and idle connection cleanup
CHANGELOG.md Documents the fix for issue #2009

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@anderbubble anderbubble marked this pull request as ready for review September 10, 2025 03:22
@anderbubble anderbubble force-pushed the 2009-wwclient-once-address-already-in-use branch from b768049 to e55d177 Compare October 14, 2025 19:00
@anderbubble anderbubble force-pushed the 2009-wwclient-once-address-already-in-use branch from e55d177 to a4bde3b Compare October 14, 2025 19:01
@mslacken mslacken merged commit ffe3dad into warewulf:main Oct 14, 2025
3 checks passed
@anderbubble anderbubble deleted the 2009-wwclient-once-address-already-in-use branch October 14, 2025 19:48
@anderbubble
Copy link
Collaborator Author

Thanks for the review!

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.

wwclient sometimes reports "address already in use" when secure=true

2 participants