Skip to content

sources/azure: remove unnecessary hostname bounce#1143

Merged
TheRealFalcon merged 1 commit into
canonical:mainfrom
cjp256:remove-hostname-bounce
Dec 10, 2021
Merged

sources/azure: remove unnecessary hostname bounce#1143
TheRealFalcon merged 1 commit into
canonical:mainfrom
cjp256:remove-hostname-bounce

Conversation

@cjp256
Copy link
Copy Markdown
Contributor

@cjp256 cjp256 commented Dec 9, 2021

Thanks to [1], the hostname is set prior to network bring-up.

The Azure data source has been bouncing the hostname during
setup(), occurring after the hostname has already been
properly configured.

Note that this doesn't prevent leaking the image's hostname
during Azure's _get_data() when it brings up ephemeral DHCP.
However, as are not guaranteed to have the hostname metadata
available from a truly "local" source, this behavior is to
be expected unless we disable send host-name from dhclient
config.

133ad2c

Signed-off-by: Chris Patterson cpatterson@microsoft.com

Additional Context

This behavior be seen easily enough by launching an Ubuntu 20.04 VM on Azure.

grep -i hostname /var/log/cloud-init.log

2021-12-09 17:16:25,706 - DataSourceAzure.py[DEBUG]: Hostname retrieved from IMDS: cpatterson-u20-x1
2021-12-09 17:16:26,093 - cc_set_hostname.py[DEBUG]: Setting the hostname to cpatterson-u20-x1 (cpatterson-u20-x1)
2021-12-09 17:16:26,093 - util.py[DEBUG]: Reading from /etc/hostname (quiet=False)
2021-12-09 17:16:26,093 - util.py[DEBUG]: Read 7 bytes from /etc/hostname
2021-12-09 17:16:26,093 - util.py[DEBUG]: Writing to /etc/hostname - wb: [644] 18 bytes
2021-12-09 17:16:26,093 - init.py[DEBUG]: Non-persistently setting the system hostname to cpatterson-u20-x1
2021-12-09 17:16:26,094 - subp.py[DEBUG]: Running command ['hostname', 'cpatterson-u20-x1'] with allowed return codes [0] (shell=False, capture=True)
2021-12-09 17:16:26,096 - atomic_helper.py[DEBUG]: Atomically writing to file /var/lib/cloud/data/set-hostname (via temporary file /var/lib/cloud/data/tmp8t_8f9ws) - w: [644] 67 bytes/chars
2021-12-09 17:16:28,658 - handlers.py[DEBUG]: start: azure-ds/bounce_network_with_azure_hostname: bounce_network_with_azure_hostname
2021-12-09 17:16:28,658 - DataSourceAzure.py[DEBUG]: Hostname in metadata is cpatterson-u20-x1
2021-12-09 17:16:28,658 - handlers.py[DEBUG]: start: azure-ds/temporary_hostname: temporary_hostname
2021-12-09 17:16:28,658 - handlers.py[DEBUG]: finish: azure-ds/temporary_hostname: SUCCESS: temporary_hostname
2021-12-09 17:16:28,658 - subp.py[DEBUG]: Running command ('hostname',) with allowed return codes [0] (shell=False, capture=True)
2021-12-09 17:16:28,662 - handlers.py[DEBUG]: finish: azure-ds/bounce_network_with_azure_hostname: SUCCESS: bounce_network_with_azure_hostname

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

Thanks to [1], the hostname is set prior to network bring-up.

The Azure data source has been bouncing the hostname during
setup(), occurring after the hostname has already been
properly configured.

Note that this doesn't prevent leaking the image's hostname
during Azure's _get_data() when it brings up ephemeral DHCP.
However, as are not guaranteed to have the hostname metadata
available from a truly "local" source, this behavior is to
be expected unless we disable `send host-name` from dhclient
config.

canonical@133ad2c

Signed-off-by: Chris Patterson <cpatterson@microsoft.com>
@cjp256 cjp256 force-pushed the remove-hostname-bounce branch from 39e7e57 to 6b4598f Compare December 9, 2021 17:41
Copy link
Copy Markdown
Contributor

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TheRealFalcon TheRealFalcon merged commit e963426 into canonical:main Dec 10, 2021
@cjp256 cjp256 deleted the remove-hostname-bounce branch April 25, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants