Closed kladiv closed 3 years ago
Just as some background, this script is for Google-created images, so e.g. "RHEL7 with no NetworkManager" is not the environment we target, as our RHEL7 does have NetworkManager.
In Linux, the hostname is a runtime value maintained by the kernel. Regardless of the presence or contents of any configuration values, the source of truth is always the value stored in memory by the kernel, which can be obtained by gethostname(2) function or the hostname(1) utility. The /etc/hostname file is historically used during startup to set the in-memory value, but since GCE VM images may be used on multiple instances and the source of the hostname is really stored in GCE, we have implemented this dynamic hostname setting script instead. That is, you can ignore /etc/hostname, and any software which attempts to read this file to get the current hostname is in error, and should be updated to one of the mechanisms listed.
This package is installed on SLES and called google-guest-configs, but the SLES version of this package does not contain the scripts under discussion, as SLES uses wicd which does not use the dhclient-script or dhclient-exit-hooks mechanisms. Hostnames on SLES are set via wicd via the DHCP response, and the helper scripts therefore don't exist.
This happens to us as well when using custom Ubuntu 16.04 images (Which were built upon GCE ubuntu-1604-lts
).
When creating a new VM from the custom image, the /etc/hostname
file is not updated and still uses the name of the VM used to create the image (Or even the VM before it?)
as said above, you can ignore /etc/hostname. what matters is the result of the hostname
command. if it is returning the wrong value, you should file a customer support case. or if you want to investigate yourself and think you found a bug, file it here.
Hello, we found an uncorrect behaviour on new deployed VM Instances from Images.
google_set_hostname
does not change static hostname (viahostnamectl
if present). After PR https://github.com/GoogleCloudPlatform/compute-image-packages/pull/544 the hostnamectl code block has beed removed.We tested on RHEL7 (but the same in CentOS7, CentOS8, RHEL8) with no NetworkManager.
Static hostname (/etc/hostname) is not changed after VM creation from Image.
In my opinion code below should be added
Another question: in SLES12, SLES15 there's not google_set_hostname (and google-compute-engine repo/packages). Is it correct? Thank you.
Best Regards, Claudio