Bug 1100178

Summary: 'hostname' return unexpected hostname after doing vmware customization with DHCP network configure
Product: [SUSE Linux Enterprise Server] Beta SUSE Linux Enterprise Server 15 Reporter: vmware gos <vmware-gos-qa>
Component: OtherAssignee: Robert Schweikert <rjschwei>
Status: CONFIRMED --- QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P3 - Medium CC: jsavanyo, kukuk, novell-updates
Version: GMC   
Target Milestone: ---   
Hardware: Other   
OS: SLES 15   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: cloud-init log with DHCP cust

Description vmware gos 2018-07-05 07:27:56 UTC
Created attachment 776154 [details]
cloud-init log with DHCP cust

'hostname' return unexpected hostname after doing vmware customization with DHCP network configure while /etc/hostname has saved expected hostname got from vmware cust.cfg file.


Reproduce steps:
1. Install cloud-init on SLES VM

2. Enable cloud-init 4 services.
systemctl enable cloud-init-local
systemctl enable cloud-init
systemctl enable cloud-config
systemctl enable cloud-final

3. Add "disable_vmware_customization: false" to /etc/cloud/cloud.cfg

4. Add below 2 lines to Unit sesstion of vmtoolsd service if they are not there:
DefaultDependencies=no
Before=cloud-init-local.service

5. Poweroff VM

6. Edit VM configuration to not check "Connect At Power On" for all DVD Drivers.

7. Select one DHCP policy to do "Customize Guest OS", in which will set one special hostname

8. Power On VM and log in to VM.

9. Execute"hostname" to check hostname is expected.

Expected Result:
Step 9, execute "hostname" on VM will display same one with which is given in Policy in Step7.
Actual Result:
Step 9, execute "hostname" on VM display different one with which is given in Policy in Step7.


cloud-init.log is attached which help for your debugging.


-VMWare QE
Comment 1 Tomáš Chvátal 2018-07-06 11:05:38 UTC
*** Bug 1100179 has been marked as a duplicate of this bug. ***
Comment 2 vmware gos 2018-08-24 18:43:34 UTC
e.g., in one of our tests, expected hostname is 'cx-gosc-testing-hostname', but execute 'hostname' get old name.

pek2-gosv-16-dhcp19:~ # cat /etc/hostname
cx-gosc-testing-hostname
pek2-gosv-16-dhcp19:~ # hostname
pek2-gosv-16-dhcp19
pek2-gosv-16-dhcp19:~ #
Comment 6 Thorsten Kukuk 2018-09-03 12:38:53 UTC
We have the case:
1. /etc/hostname is modified
2. the hostname is not updated

hostnamectl does update both, /etc/hostname and /usr/bin/hostname. As we have the above case, it cannot be the case that hostnamectl did fail, else /etc/hostname would not contain the new hostname.

This means:
1. the hostname from vmware cust.cfg file is written by something else to /etc/hostname, but not this cloud-init function.
2. the other cases of this cloud-init function got executed, which only write /etc/hostname, but not set the hostname.

I have no idea what the problem could be, somebody needs to analyze, how and when /etc/hostname is updated with the new hostname from vmware cust.cfg.
Comment 7 vmware gos 2018-11-16 06:13:38 UTC
This issue exist on SLES 12 SP4 too.

pek2-gosv-16-dhcp179:/var/log # cloud-init -v
/usr/bin/cloud-init 18.2

pek2-gosv-16-dhcp179:/var/log # zypper info open-vm-tools
...
Information for package open-vm-tools:
--------------------------------------
Repository     : SLES12-SP4-Pool
Name           : open-vm-tools
Version        : 10.3.0-2.6
Arch           : x86_64
Vendor         : SUSE LLC <https://www.suse.com/>
Support Level  : Level 3
Installed Size : 1.2 MiB
Installed      : Yes (automatically)
Status         : up-to-date
Source package : open-vm-tools-10.3.0-2.6.src

pek2-gosv-16-dhcp179:/var/log # grep hostname cloud-init.log
2018-11-16 05:48:11,143 - cc_set_hostname.py[DEBUG]: Setting the hostname to cx-gosc-dhcp-vmname.cx-testing (cx-gosc-dhcp-vmname)
2018-11-16 05:48:11,144 - util.py[DEBUG]: Running command ['hostnamectl', 'set-hostname', 'cx-gosc-dhcp-vmname'] with allowed return codes [0] (shell=False, capture=True)
2018-11-16 05:48:11,180 - __init__.py[DEBUG]: Non-persistently setting the system hostname to cx-gosc-dhcp-vmname
2018-11-16 05:48:11,180 - util.py[DEBUG]: Running command ['hostname', 'cx-gosc-dhcp-vmname'] with allowed return codes [0] (shell=False, capture=True)
2018-11-16 05:48:26,759 - util.py[DEBUG]: Reading from /var/lib/cloud/data/set-hostname (quiet=False)
2018-11-16 05:48:26,759 - util.py[DEBUG]: Read 83 bytes from /var/lib/cloud/data/set-hostname
2018-11-16 05:48:26,759 - cc_set_hostname.py[DEBUG]: No hostname changes. Skipping set-hostname
2018-11-16 05:48:27,188 - stages.py[DEBUG]: Running module set_hostname (<module 'cloudinit.config.cc_set_hostname' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_set_hostname.pyc'>) with frequency once-per-instance
2018-11-16 05:48:27,188 - handlers.py[DEBUG]: start: init-network/config-set_hostname: running config-set_hostname with frequency once-per-instance
2018-11-16 05:48:27,188 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/iid-vmware-1Y3aPtWU/sem/config_set_hostname - wb: [644] 20 bytes
2018-11-16 05:48:27,189 - helpers.py[DEBUG]: Running config-set_hostname using lock (<FileLock using file '/var/lib/cloud/instances/iid-vmware-1Y3aPtWU/sem/config_set_hostname'>)
2018-11-16 05:48:27,189 - util.py[DEBUG]: Reading from /var/lib/cloud/data/set-hostname (quiet=False)
2018-11-16 05:48:27,189 - util.py[DEBUG]: Read 83 bytes from /var/lib/cloud/data/set-hostname
2018-11-16 05:48:27,189 - cc_set_hostname.py[DEBUG]: No hostname changes. Skipping set-hostname
2018-11-16 05:48:27,189 - handlers.py[DEBUG]: finish: init-network/config-set_hostname: SUCCESS: config-set_hostname ran successfully
2018-11-16 05:48:27,189 - stages.py[DEBUG]: Running module update_hostname (<module 'cloudinit.config.cc_update_hostname' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_update_hostname.pyc'>) with frequency always
2018-11-16 05:48:27,189 - handlers.py[DEBUG]: start: init-network/config-update_hostname: running config-update_hostname with frequency always
2018-11-16 05:48:27,190 - helpers.py[DEBUG]: Running config-update_hostname using lock (<cloudinit.helpers.DummyLock object at 0x7f5eba493a10>)
2018-11-16 05:48:27,190 - cc_update_hostname.py[DEBUG]: Updating hostname to cx-gosc-dhcp-vmname.cx-testing (cx-gosc-dhcp-vmname)
2018-11-16 05:48:27,190 - util.py[DEBUG]: Running command ['hostname'] with allowed return codes [0] (shell=False, capture=True)
2018-11-16 05:48:27,192 - __init__.py[DEBUG]: Attempting to update hostname to cx-gosc-dhcp-vmname in 1 files
2018-11-16 05:48:27,192 - util.py[DEBUG]: Writing to /var/lib/cloud/data/previous-hostname - wb: [644] 19 bytes
2018-11-16 05:48:27,193 - handlers.py[DEBUG]: finish: init-network/config-update_hostname: SUCCESS: config-update_hostname ran successfully
pek2-gosv-16-dhcp179:/var/log # cat /var/lib/cloud/data/set-hostname
{
 "fqdn": "cx-gosc-dhcp-vmname.cx-testing",
 "hostname": "cx-gosc-dhcp-vmname"
}
pek2-gosv-16-dhcp179:/var/log # hostname
pek2-gosv-16-dhcp179
pek2-gosv-16-dhcp179:/var/log #


-VMWare GOS QA
Comment 8 Mr. VMware Engineering 2019-02-26 01:24:05 UTC
This issue also exist SLES 15SP1Beta3 cloud-init with version 18.4.
pek2-gosv-16-dhcp167:/var/log # cloud-init -v
/usr/bin/cloud-init 18.4

And I tried 'hostnamectl set-hostname sles-dhcp-vm-0704-1' on SLES 15SP1Beta3, both /etc/hostname and hostname are correct. But Reboot VM, The issue of this PR re-occur.

pek2-gosv-16-dhcp167:~ # hostname
sles-dhcp-vm-0704-1
pek2-gosv-16-dhcp167:~ # cat /etc/hostname 
sles-dhcp-vm-0704-1
pek2-gosv-16-dhcp167:~ # reboot 
pek2-gosv-16-dhcp167:~ # hostname
pek2-gosv-16-dhcp167
pek2-gosv-16-dhcp167:~ # cat /etc/hostname 
sles-dhcp-vm-0704-1

-VMWare GOS QA
Comment 9 vmware gos 2019-03-07 07:57:53 UTC
VMWARE PR: https://bugzilla.eng.vmware.com/show_bug.cgi?id=2153583

-VMWare GOS QA