-
Notifications
You must be signed in to change notification settings - Fork 80
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
base: master
Are you sure you want to change the base?
Conversation
@tayterz2 BTW, please use rebase master, thank you! |
@Yu-Jack - I rebased 2 days ago, and currently github reports this branch as caught up. What am I missing? Thanks! |
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. |
@Yu-Jack - Done, thanks! |
@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'` |
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.
@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).
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.
@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.
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 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.
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.
@ihcsim There are three sub-issues in this topic
- For first node, we don't bring customized hostname. (The fix is https://github.com/harvester/harvester-installer/pull/931/files#diff-fb345406e175053d95f23645fa17f1ba365649c8baafd1df4313cf662aaa64c5)
- For joiner node, we don't bring customized hostname. (The fix is feat: add config.nodeName to joiner rancher/rancherd#50)
- 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 setting127.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.
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.
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.
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.
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.
out, err = exec.Command("/bin/sh", "-c", hcmd).Output() | ||
if err != nil { | ||
logrus.Errorf("failed to get hostname: %v", err) | ||
return "", err | ||
} |
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.
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 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! |
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.