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

Ubuntu 18.04 --deprovision causes host name to become localhost #2312

Closed
anamariaduta opened this issue Jul 20, 2021 · 2 comments
Closed

Ubuntu 18.04 --deprovision causes host name to become localhost #2312

anamariaduta opened this issue Jul 20, 2021 · 2 comments

Comments

@anamariaduta
Copy link

We have the following scenario: we are deprovisioning an image deployed from the Portal and use it to create a new virtual machine that has the same hostname as the original one. Once it is deployed, the hostname of the virtual machine is changed to localhost, instead of the name that we have set in the Portal, which is the name of the original VM.

Here are more details:

  1. Customer has a VM named “Original” (hostname is then also named as Original).
  2. We then deprovision this VM with no issues, and capture an image from the Azure Portal.
  3. We then use this image to create a VM with the same name as the original VM named “Original”
  4. When we then login to the VM and check the Hostname it is reported as local.host.localadmin (and not the defined Hostname/Portal VM name “Original”.
  5. If we then use that same image to create a new VM with a separate name like “OriginalNew”, the VM will have the new Hostname that has been given.

Distro and WALinuxAgent details (please complete the following information):

  • Distro and Version: Ubuntu 18.04
  • WALinuxAgent version: 2.3.1.1

Additional context
I see a similar bug opened in 2018 that has been closed:
Ubuntu 18.04 --deprovision causes host name to become localhost · Issue #1398 · Azure/WALinuxAgent (github.com)
The workaround of adding the hostname manually in /etc/hostname works but we would not have to do that.

Log file attached
Here is a copy of the cloud.init file showing the name being changed:
2021-07-19 11:22:39,332 - init.py[DEBUG]: no work necessary for renaming of [[u'00:22:48:9a:23:87', 'eth0', 'hv_netvsc', '0x3']]
2021-07-19 11:22:39,332 - handlers.py[DEBUG]: start: init-network/setup-datasource: setting up datasource
2021-07-19 11:22:39,333 - handlers.py[DEBUG]: start: azure-ds/setup: setup
2021-07-19 11:22:39,333 - DataSourceAzure.py[DEBUG]: negotiating for 932F400A-9A3C-9B49-8F5D-EB1D67E7EDEE (new_instance=False)
2021-07-19 11:22:39,333 - handlers.py[DEBUG]: start: azure-ds/_negotiate: _negotiate
2021-07-19 11:22:39,333 - handlers.py[DEBUG]: start: azure-ds/bounce_network_with_azure_hostname: bounce_network_with_azure_hostname
2021-07-19 11:22:39,333 - DataSourceAzure.py[DEBUG]: Hostname in metadata is P105-Prod-GothiaPOC-Calibrate
2021-07-19 11:22:39,333 - handlers.py[DEBUG]: start: azure-ds/temporary_hostname: temporary_hostname
2021-07-19 11:22:39,334 - handlers.py[DEBUG]: finish: azure-ds/temporary_hostname: SUCCESS: temporary_hostname
2021-07-19 11:22:39,334 - util.py[DEBUG]: Running command ('hostname',) with allowed return codes [0] (shell=False, capture=True)
2021-07-19 11:22:39,342 - util.py[DEBUG]: Running command ['hostnamectl', 'set-hostname', 'P105-Prod-GothiaPOC-Calibrate'] with allowed return codes [0] (shell=False, capture=True)
2021-07-19 11:22:39,391 - handlers.py[DEBUG]: start: azure-ds/perform_hostname_bounce: perform_hostname_bounce
2021-07-19 11:22:39,391 - util.py[DEBUG]: Reading from /etc/os-release (quiet=False)
2021-07-19 11:22:39,393 - util.py[DEBUG]: Read 393 bytes from /etc/os-release
2021-07-19 11:22:39,394 - DataSourceAzure.py[DEBUG]: pubhname: publishing hostname [hostname=P105-Prod-GothiaPOC-Calibrate policy=True interface=eth0]
2021-07-19 11:22:39,394 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2021-07-19 11:22:39,394 - util.py[DEBUG]: Read 12 bytes from /proc/uptime
2021-07-19 11:22:39,394 - util.py[DEBUG]: Running command ['sh', '-xc', 'i=$interface; x=0; ifdown $i || x=$?; ifup $i || x=$?; exit $x'] with allowed return codes [0] (shell=False, capture=False)
2021-07-19 11:22:40,212 - util.py[DEBUG]: Reading from /proc/uptime (quiet=False)
2021-07-19 11:22:40,213 - util.py[DEBUG]: Read 12 bytes from /proc/uptime
2021-07-19 11:22:40,213 - util.py[DEBUG]: publishing hostname took 0.818 seconds (0.82)
2021-07-19 11:22:40,213 - handlers.py[DEBUG]: finish: azure-ds/perform_hostname_bounce: SUCCESS: perform_hostname_bounce
2021-07-19 11:22:40,213 - util.py[DEBUG]: Running command ['hostnamectl', 'set-hostname', 'localhost.localdomain'] with allowed return codes [0] (shell=False, capture=True)
2021-07-19 11:22:40,256 - handlers.py[DEBUG]: finish: azure-ds/bounce_network_with_azure_hostname: SUCCESS: bounce_network_with_azure_hostname
2021-07-19 11:22:40,257 - DataSourceAzure.py[DEBUG]: negotiating with fabric via agent command builtin

@narrieta
Copy link
Member

@anhvoms could you take a look? thanks!

@anhvoms
Copy link
Collaborator

anhvoms commented Apr 27, 2023

Original poster indicated he could not reproduce the issue in #1398

@anhvoms anhvoms closed this as completed Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants