-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
networking: Update fqdnOrHostName logic to handle empty hostName #357647
base: master
Are you sure you want to change the base?
Conversation
What is the expected use or scenario for an empty string hostname? |
Delegate the hostname into cloud-init or dhcp. Default behavior in srvos server profile: |
What do you think @roberth ? maybe its prefered simply remove this line from |
defaultText = literalExpression '' | ||
if cfg.domain == null then cfg.hostName else cfg.fqdn | ||
''; | ||
default = if (cfg.hostName == "" || cfg.domain == null) |
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.
default = if (cfg.hostName == "" || cfg.domain == null) | |
default = if (cfg.hostName != "" && cfg.domain == null) |
shouldn't this be like this? otherwise we take an empty hostname as before.
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.
Not exactly, the regression occurs when hostName
is empty and domain
is defined. In that case, I want fqdnOrHostname
to return ""
, not an error (as networking.fqdn
does).
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.
I find the condition a bit hard to understand when we re-use the empty string hostname in that case.
Also I think this not really covers the original usecase anymore. Before you would always get either a hostname or a fqdn where as empty string probably breaks most usages of it.
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.
I understand your point, so the regression comes from os-release
changes i pointed above, leveraging this function, as os-release
MUST not depend on whether hostName is defined or not
@SuperSandro2000 Can I help with this? I have a fleet of servers blocked for 24.11 update. |
A different path to solve this: |
Regardless of solving my issue with this PR #359571, it is inconsistent that the It should either:
or
|
Motivation for this change
The current logic for
networking.fqdnOrHostName
does not account for cases wherehostName
is an empty string. This can lead to unexpected behavior in configurations wherehostName
is not set. This change updates the logic to handle emptyhostName
values appropriately.Things done
networking.fqdnOrHostName
to check ifhostName
is an empty string.defaultText
to reflect the new logic.hostName
is empty ordomain
is unset.Testing
./result/bin/
).nix path-info -S
before and after).