Skip to content
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

Allow for a Fully-Qualified Hostname #931

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tayterz2
Copy link
Contributor

Problem:
When using domain names in hostnames, inform RancherD and the Dashboard that this is the proper hostname.

Solution:
Add hostname to rancherd node adds, and perform "hostnamectl" instead of "hostname" to pull the FQDN from the hosts.

Related Issue:
harvester/harvester#7312

Test plan:
Install Harvester with an FQDN as hostname (taylor.rancher.io) and observe that same hostname in the "hosts" and "node" fields throughout.

@tayterz2 tayterz2 requested a review from Yu-Jack February 14, 2025 17:10
@Yu-Jack
Copy link
Contributor

Yu-Jack commented Feb 24, 2025

@tayterz2 BTW, please use rebase master, thank you!

@tayterz2
Copy link
Contributor Author

@Yu-Jack - I rebased 2 days ago, and currently github reports this branch as caught up. What am I missing?

Thanks!
Taylor

@Yu-Jack
Copy link
Contributor

Yu-Jack commented Feb 25, 2025

Hi @tayterz2 I think you can rebase again. Or just open another branch based on master, cherry-pick your commit and force push it to this branch again.

@tayterz2
Copy link
Contributor Author

@Yu-Jack - Done, thanks!

@Yu-Jack
Copy link
Contributor

Yu-Jack commented Feb 26, 2025

@tayterz2 If you use rebase, the commits wouldn't be 19. Could try it one more time? BTW, you could squash your commits into one commit? Thanks.

)

// find node hostname
hcmd = `hostnamectl --static | tr -d '\r\n'`
Copy link
Contributor

Choose a reason for hiding this comment

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

@Yu-Jack with the changes in rancher/rancherd#50, do we still need to use hostnamectl or can we switch back to Go's os.Hostname() (which uses uname or /proc/sys/kernel/hostname, if Linux).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ihcsim not exactly - os.Hostname() can't return the Fully-Qualified hostname of a host, so rancher/harvester hosts end up with shortened names. This is a huge problem for customers with larger Harvester clusters spanning multiple domain names. @Yu-Jack 's fix only addresses the rancherd end of the problem (primarily shows up in node joins), not the Harvester console or install (first node) scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

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

i was hoping that once we appease rancher everywhere, the fqdn becomes the (static and transient) hostname where we no longer need to use the short name.

Copy link
Contributor

@Yu-Jack Yu-Jack Feb 27, 2025

Choose a reason for hiding this comment

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

@ihcsim There are three sub-issues in this topic

  1. For first node, we don't bring customized hostname. (The fix is https://github.com/harvester/harvester-installer/pull/931/files#diff-fb345406e175053d95f23645fa17f1ba365649c8baafd1df4313cf662aaa64c5)
  2. For joiner node, we don't bring customized hostname. (The fix is feat: add config.nodeName to joiner rancher/rancherd#50)
  3. Which name should Harvester Install show? Which command should we use to fetch proper hostname hostname -f only shows the short one. We don't have this setting 127.0.0.1 harvester1.dap.sys harvester1 in /etc/hosts

For the 1 and 2, there is no doubt. We should pass customized hostname to rancher. But, for 3, we might need a discussion about it. This comment (harvester/harvester#7312 (comment)) is a warp up.

Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need the short name? i thought the only place where the short name comes from is https://github.com/rancher/rancherd/blob/6f7255eb0eafd3294e3ec5140d617ff1831b0b9b/pkg/resources/resources.go#L55-L62.

Copy link
Contributor

Choose a reason for hiding this comment

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

Harvester Installer Dashboard uses hostname or os.Hostname to fetch it. Even, you pass FQDN to rancherd in this PR, it stills shows short one. But, I think we should display FQDN in Harvester Installer Dashboard, so we need to change the way how it fetches.

Comment on lines +1250 to +1254
out, err = exec.Command("/bin/sh", "-c", hcmd).Output()
if err != nil {
logrus.Errorf("failed to get hostname: %v", err)
return "", err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use CombinedOutput() to capture both stdout and stderr. Also, if err !=nil, out should be logged too to capture the actual Linux outputs. In most cases, err only capture Go-specific errors. It will be great if we can revert back to using os.Hostname(), for portability.

@tayterz2
Copy link
Contributor Author

@tayterz2 If you use rebase, the commits wouldn't be 19. Could try it one more time? BTW, you could squash your commits into one commit? Thanks.

@Yu-Jack
Yes - my git ignorance is showing. Please take a look now, I think I've gotten it fixed up.

Thanks,
Taylor

@Yu-Jack
Copy link
Contributor

Yu-Jack commented Feb 27, 2025

@tayterz2 If you use rebase, the commits wouldn't be 19. Could try it one more time? BTW, you could squash your commits into one commit? Thanks.

@Yu-Jack Yes - my git ignorance is showing. Please take a look now, I think I've gotten it fixed up.

Thanks, Taylor

@tayterz2 Nice, it's good now. But, do you think we need to split this PR to different PRs to focus on different issues?

@tayterz2
Copy link
Contributor Author

@

@tayterz2 If you use rebase, the commits wouldn't be 19. Could try it one more time? BTW, you could squash your commits into one commit? Thanks.

@Yu-Jack Yes - my git ignorance is showing. Please take a look now, I think I've gotten it fixed up.
Thanks, Taylor

@tayterz2 Nice, it's good now. But, do you think we need to split this PR to different PRs to focus on different issues?

Completely understand why it might be 2 issues and 2 PRs from you devs' perspective - but from the customer's viewpoint it is only one. The FQDN doesn't work, or it does. I'll leave to you guys to let me know which way to go - happy to accommodate either way so long as we can get both fixes into v1.5!

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