Skip to content

Fail fast optimization to is_resolvable.#6772

Merged
holmanb merged 1 commit into
canonical:mainfrom
aale24:is_resolvable_fix
Mar 11, 2026
Merged

Fail fast optimization to is_resolvable.#6772
holmanb merged 1 commit into
canonical:mainfrom
aale24:is_resolvable_fix

Conversation

@aale24
Copy link
Copy Markdown
Contributor

@aale24 aale24 commented Feb 27, 2026

Description

Building on the previous optimization in #2040, this adds an additional optimization to fail early when the hostname is not resolvable at all.

This change reduces unnecessary DNS queries to invalid hostnames like "does-not-exist.example.com.", "example.invalid.", and "cloud_init_expected_not_found" that were observed in Route 53 logs.

This optimization has been stable in Amazon Linux for nearly a year.

Note: This is a resubmission of #6766 with the original author contributing directly as requested.

Proposed Commit Message

feat(util): fail early when hostname is not resolvable in is_resolvable

Building on the previous optimization in #2040, add an additional 
optimization to fail early when the hostname is not resolvable at all.

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.

I left one nitpick for the code. Also, we use "conventional commits" for commit message format.

Otherwise this looks good to me.

Comment thread cloudinit/util.py Outdated
"""
global _DNS_REDIRECT_IP
parsed_url = parse.urlparse(url)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please don't add unnecessary whitespace changes.

Building on the previous optimization in canonical#2040, add an additional
optimization to fail early when the hostname is not resolvable at all.
@joeysk2012
Copy link
Copy Markdown

@holmanb can you take another look? Thanks.

@holmanb holmanb merged commit 7132625 into canonical:main Mar 11, 2026
22 checks passed
blackboxsw pushed a commit to blackboxsw/cloud-init that referenced this pull request Apr 13, 2026
…le (canonical#6772)

Building on the previous optimization in canonical#2040, add an additional 
optimization to fail early when the hostname is not resolvable at all.
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.

3 participants