Skip to content

CA-412636: hostname changed to localhost with static IP and reboot #6546

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
merged 1 commit into from
Jul 1, 2025

Conversation

liulinC
Copy link
Collaborator

@liulinC liulinC commented Jun 20, 2025

According to
https://www.freedesktop.org/software/systemd/man/latest/hostname.html Systemd set hostname with following sequence

  • kernel parameter, systemd.hostname
  • static hostname in /etc/hostname
  • transient hostname like DHCP
  • localhost at systemd compile time

Once the host is configured with static IP and reboot, it would just lost its hostname as no DHCP or static IP available.

However, the hostname is critical to AD function as it construct the machine account.

The hostname should be persisted as static name during joining AD, this is also what PBIS does.

Note: the static hostname is not cleaned during domain leave. This is by intention to avoid losing hostname after reboot with static IP

cba2f1d tried to resovle the issue and update /etc/resolv.conf However, /etc/resolv.conf does not help and conflict with xcp-networkd, as networkd override the configure every 5 minutes Here we just revert the resolv.conf update

@edwintorok
Copy link
Contributor

I can't find commit 0307adc6, do you have the full git hash and title?

@liulinC liulinC force-pushed the private/linl/xsi-1918-pr branch from 5b54001 to ce45a11 Compare June 20, 2025 10:24
@liulinC
Copy link
Collaborator Author

liulinC commented Jun 20, 2025

I can't find commit 0307adc6, do you have the full git hash and title?

Sorry, I got the commit ID from wrong branch (my dev branch before merged to master), thus wrong commit id.
it should be cba2f1d, and updated the commit message.

@lindig
Copy link
Contributor

lindig commented Jun 20, 2025

So the approach of rewriting resolve.conf was wrong? But this was done for a purpose - it that still achieved?

@liulinC
Copy link
Collaborator Author

liulinC commented Jun 21, 2025

So the approach of rewriting resolve.conf was wrong? But this was done for a purpose - it that still achieved?

writing resolve.conf is NOT wrong, on the contrary, it is right
It absolutely make sense to write domain into resolv.conf . (there is a customer do expect that and there is an XSI for that).

However, simply write to that file conflict with networkd, I may update later to call networkd to update the domain later, (update_config). but that will require more test.

This PR overriding the hostname just follows what PBIS does, and it resolve the localhost issue.

@edwintorok
Copy link
Contributor

Aren't we going to regress the fix for XSI-1918 though? I'd rather wait until we have a fix that works for both CA-412636 and XSI-1918 and merge it in the same PR so we don't risk breaking AD for existing users.

@lindig
Copy link
Contributor

lindig commented Jun 26, 2025

I am also confused about the relationship between the code that is removed and the new code - hence my question earlier. This PR should present more context how these problems are related.

@liulinC
Copy link
Collaborator Author

liulinC commented Jun 27, 2025

1918

The deleted code does not fix XSI-1918.
The real fix for XSI-1918 is:

  • update hostname order in /etc/hosts. e.g: the un-removed part of cba2f1d
  • This PR, e.g: set static hostname during join pool.

The removed code does not have any issue as it was override by xcp-network anyway. (and It will not cause customer any trouble)

@liulinC
Copy link
Collaborator Author

liulinC commented Jun 27, 2025

I am also confused about the relationship between the code that is removed and the new code - hence my question earlier. This PR should present more context how these problems are related.
in XSI-1918, we found two main issues.

  1. The hostname is no write into /etc/hosts in right order, as stated in cba2f1d, and in that PR we
  • fix the order issue
  • push hostname to DNS server by best effort. (not a regression), so pool numbers can resolve each other by hostname with static IP setting
  • write domain to /etc/resolv.conf. so the default domain is the join domain. (not a regression, but an enhancement)
  1. hostname should be set to static hostname like PBIS during pool Jon.
  • This PR fix the issue.
  • I found that the /etc/resolv.conf configuration is conflict with scp-networkd. and it is an enhancement, (Not the issue reported by XSI-1918). So I revert the change in this commit.

Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

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

I see, so this only partially reverts the previous change, in particular the resolv.conf update which introduced a bug as it conflicted with networkd, and in addition it sets the hostname using an external command.

According to
https://www.freedesktop.org/software/systemd/man/latest/hostname.html
Systemd set hostname with following sequence
- kernel parameter, systemd.hostname
- static hostname in /etc/hostname
- transient hostname like DHCP
- localhost at systemd compile time

Once the host is configured with static IP and reboot, it would
just lost its hostname as no DHCP or static IP available.

However, the hostname is critical to AD function as it construct the
machine account.

The hostname should be persisted as static name during joining AD,
this is also what PBIS does.

Note: the static hostname is not cleaned during domain leave.
This is by intention to avoid losing hostname after reboot with static IP

cba2f1d tried to resovle the issue and update /etc/resolv.conf
However, /etc/resolv.conf does not help and conflict with
xcp-networkd, as networkd override the configure every 5 minutes
Here we just revert the resolv.conf update. Other parts of that commit
can still benifit as it push the hostname to DNS

Signed-off-by: Lin Liu <[email protected]>
@liulinC liulinC force-pushed the private/linl/xsi-1918-pr branch from ce45a11 to 267c414 Compare July 1, 2025 09:24
@liulinC liulinC enabled auto-merge July 1, 2025 09:24
@liulinC liulinC added this pull request to the merge queue Jul 1, 2025
Merged via the queue into xapi-project:master with commit aa1653a Jul 1, 2025
16 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.

3 participants