-
Notifications
You must be signed in to change notification settings - Fork 14
chore(cloud-init): truncate hostnames in determineHostname #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jepio
merged 1 commit into
flatcar:flatcar-master
from
RiRa12621:rira12621-hostname-truncate
Apr 3, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a discussion at some point about using the FQDN vs the short name as the hostname (and potentially adding the fqdn in
/etc/hosts). Some projects (like afterburn) prefer to use the FQDN, some projects prefer the short name.I think that if the hostname is too large, we should make an attempt to use the short name. After which we should truncate the short name if it continues to be too large.
The reason is that this way, we at least get a valid hostname, and not a truncated FQDN (if the short name is within the 63 character limit). The full FQDN will still be valid if set in
/etc/hostsalong side the short name (if each element of the hostname is itself valid).@jepio @RiRa12621 what do you folks think?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, if we have something like this:
And we truncate at 63 using the logic here, we get:
this-hostname-is-precisely-than-sixty-three-characters-in--size. Which is fine.But if we have:
we end up with:
this-hostname-is-a-bit-larger-than-sixty-three-characters.examp. Which is neither the FQDN that we want, nor a short name. If we go with the short name approach, we at least end up with a valid short name ofthis-hostname-is-a-bit-larger-than-sixty-three-characters, and we can set the correct FQDN in/etc/hosts.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the second example, the code does the split on
.before truncating, so the outcome is exactly as you describe (we don't end up with a partial FQDN).I think in general the hostname and (/etc/hostname) should be just the first label, and the FQDN should be resolved through DNS.
cloud-init and coreos-cloudinit support
manage_etc_hosts: truefor those who need it.