Skip to content

fix(net): do not resolve IPs when netloc contains a port#6841

Merged
holmanb merged 1 commit into
canonical:mainfrom
Ndukiye:fix-ip-fastpath-port-handling
Apr 17, 2026
Merged

fix(net): do not resolve IPs when netloc contains a port#6841
holmanb merged 1 commit into
canonical:mainfrom
Ndukiye:fix-ip-fastpath-port-handling

Conversation

@Ndukiye
Copy link
Copy Markdown
Contributor

@Ndukiye Ndukiye commented Apr 15, 2026

Proposed Commit Message

fix(util): include port-stripped hostname in IP fast-path check

The existing IP fast-path optimization only checked parsed_url.netloc,
which includes port information. This meant IP URLs with ports (e.g.
http://169.254.169.254:80) did not benefit from the optimization and
still triggered DNS resolution.

This improves the existing logic by using parsed_url.hostname, which
correctly excludes port information while preserving IP detection.

Fixes #6557

Additional Context

Test Steps

Tested with:
tox -e py3

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Thanks for the proposal.

Comment thread .gitignore Outdated
Comment thread cloudinit/util.py Outdated
Comment thread tests/unittests/test_util.py
@holmanb holmanb changed the title Fix IP fast-path handling for URLs with ports fix(net): do not resolve IPs when netloc contains a port Apr 15, 2026
@Ndukiye Ndukiye force-pushed the fix-ip-fastpath-port-handling branch from fc00cbc to 8cd2f79 Compare April 15, 2026 21:41
Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

One nit, otherwise this looks good to me.

Comment thread .gitignore Outdated
@Ndukiye Ndukiye force-pushed the fix-ip-fastpath-port-handling branch from fc54536 to b30b2b4 Compare April 16, 2026 07:03
@Ndukiye Ndukiye requested a review from holmanb April 16, 2026 10:18
Copy link
Copy Markdown
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

Thanks, @Ndukiye!

@holmanb holmanb merged commit dd28a36 into canonical:main Apr 17, 2026
17 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