rancher / os

Tiny Linux distro that runs the entire OS as Docker containers
https://rancher.com/docs/os/v1.x/en/
Apache License 2.0
6.45k stars 656 forks source link

DHCP client does not register the configured hostname #2759

Open janeczku opened 5 years ago

janeczku commented 5 years ago

RancherOS Version: (ros os version) v1.5.1

Where are you running RancherOS? (docker-machine, AWS, GCE, baremetal, etc.) vSphere v1.5.0.

Actual behaviour:

per https://github.com/rancher/os/issues/627#issuecomment-460618187):

I am deploying RancherOS from Rancher vSphere provider, which sets the hostname according to node name defined in Rancher UI.

In general, the hostname gets applied correctly (I can see it on the console and it gets reported correctly by VMware Tools).

However, in the DHCP request it contains the default hostname rancher so it gets registered with this name in DNS (what is not intended).

Like mentioned in the initial issue I can use sudo system-docker restart network promote the correct hostname to DHCP after RancherOS is initialized.

But of course I don't want to run this command manually in the automated process of provisioning RancherOS with Rancher vSphere provider.

TLDR: Rancher node IP addresses get registered with the incorrect default hostname rancher resulting in incorrect DNS entries, e.g. rancher.<enterprise-domain>.

Expected behaviour:

When hostname is changed from the default rancher to the one specified in cloud-config or via docker machine, then a DHCP renew request should be send in order to register the correct hostname.

niusmallnan commented 5 years ago

I can reproduce this issue. The key point is that the hostname setting is implemented by docker-machine through ssh, so the network is initialized before setting hostname. We can get the hostname config from /var/lib/rancher/conf/cloud-config.d/machine-hostname.ym.

When netconf initiated the dhcp request, ros has not yet obtained the hostname from docker-machine, so the dhcpcd always use rancher hostname.

There are several options for solving this problem:

  1. Update rancher/machine, restart the network after it sets the hostname
  2. Let ros netconf detect the hostname change and re-initiate the dhcp request with the new hostname

Reference:

tivrobo commented 5 years ago

I'm passing this into guestinfo.cloud-init.config.data as a workaround

#cloud-config
runcmd:
  - sudo nohup `sleep 60; system-docker restart network` &>/dev/null &
tsmithco commented 3 years ago

This is still an issue with the current version of rancheros - 1.5.8

PrplHaz4 commented 3 years ago

cc @olljanat - any chance this is resolved in BurmillaOS?

olljanat commented 3 years ago

@PrplHaz4 is this same as https://github.com/burmilla/os/issues/52 ? I expected that it was new bug on BurmillaOS. Good to know if that is older thing...

PrplHaz4 commented 3 years ago

@PrplHaz4 is this same as burmilla#52 ? I expected that it was new bug on BurmillaOS. Good to know if that is older thing...

Looks and sounds the same to me, but I probably won't have any time to test/confirm in the near future.