FS#72918 - [cloud-init] should depend on inetutils because of DataSourceAzure

Attached to Project: Community Packages
Opened by Alexander E. Patrakov (patrakov) - Sunday, 05 December 2021, 01:13 GMT
Last edited by David Runge (dvzrv) - Tuesday, 22 February 2022, 08:03 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To David Runge (dvzrv)
Christian Rebischke (Shibumi)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

I have tried to import the official Arch Linux cloud image from https://mirror.pkgbuild.com/images/v20211201.40458/Arch-Linux-x86_64-cloudimg-20211201.40458.qcow2 into Microsoft Azure. The steps taken (based on https://docs.microsoft.com/en-us/azure/virtual-machines/linux/create-upload-generic) were:

* Convert the image to fixed-vhd format
* Create a storage account
* Upload the image
* Create a disk from it
* Create a VM from this disk
* Provide the following cloud-config:

```
#cloud-config
fqdn: archlinux-on-azure
users:
- name: user
sudo: "ALL=(ALL) NOPASSWD: ALL"
ssh_authorized_keys:
- "ssh-ed25519 AAAA... my-ssh-key"
shell: "/bin/bash"
```

Result: cloud-init failed to run in the resulting Azure VM, because it could not execute the "hostname" command to set the host name. The log (extracted by attaching the disk to a different instance) is attached. Fixing up the image by installing inetutils was sufficient for cloud-init to run successfully.

Conclusion: cloud-init must have a dependency on inetutils, because this is the package that provides the "hostname" program, without which cloud-init does not run at all on Azure and does not continue e.g. provisioning user accounts.

I have tried to reproduce this locally without Azure, using the "nocloud" data source, but it appears that cloud-init can set the hostname without calling "hostanme" in this case. So the bug is Azure-specific, and you can find explicit references to the "hostname" command if you look into /usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceAzure.py .
This task depends upon

Closed by  David Runge (dvzrv)
Tuesday, 22 February 2022, 08:03 GMT
Reason for closing:  Upstream
Additional comments about closing:  Fixed with the release of cloud-init 22.1
Comment by Alexander E. Patrakov (patrakov) - Sunday, 05 December 2021, 01:13 GMT
[user@archlinux-on-azure ~]$ pacman -Q cloud-init
cloud-init 21.4-1
Comment by Alexander E. Patrakov (patrakov) - Sunday, 05 December 2021, 01:17 GMT
Sorry for the damaged user-data formatting, re-attaching the user-data used for non-Azure testing as a file. The only difference is the hostname.
Comment by David Runge (dvzrv) - Sunday, 05 December 2021, 11:00 GMT
@patrakov: Thanks for the report.

Hm, I was under the impression that this has been finally fixed upstream (by wCPO) and relies on systemd's hostnamectl if hostname is not available.
Comment by nl6720 (nl6720) - Sunday, 05 December 2021, 11:50 GMT Comment by Alexander E. Patrakov (patrakov) - Sunday, 05 December 2021, 11:52 GMT
You are citing the wrong file. The problematic use of "hostname" is in the other place, see https://github.com/canonical/cloud-init/blob/main/cloudinit/sources/DataSourceAzure.py#L262
Comment by Alexander E. Patrakov (patrakov) - Sunday, 05 December 2021, 11:56 GMT
Relevant part of the log:
```
------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/cloudinit/subp.py", line 257, in subp
sp = subprocess.Popen(bytes_args, stdout=stdout,
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: b'hostname'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/cloudinit/cmd/main.py", line 689, in status_wrapper
ret = functor(name, args)
File "/usr/lib/python3.9/site-packages/cloudinit/cmd/main.py", line 411, in main_init
init.setup_datasource()
File "/usr/lib/python3.9/site-packages/cloudinit/stages.py", line 443, in setup_datasource
self.datasource.setup(is_new_instance=self.is_new_instance())
File "/usr/lib/python3.9/site-packages/cloudinit/sources/helpers/azure.py", line 66, in impl
return func(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceAzure.py", line 854, in setup
fabric_data = self._negotiate()
File "/usr/lib/python3.9/site-packages/cloudinit/sources/helpers/azure.py", line 66, in impl
return func(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceAzure.py", line 1509, in _negotiate
self.bounce_network_with_azure_hostname()
File "/usr/lib/python3.9/site-packages/cloudinit/sources/helpers/azure.py", line 66, in impl
return func(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceAzure.py", line 384, in bounce_network_with_azure_hostname
with temporary_hostname(azure_hostname, self.ds_cfg,
File "/usr/lib/python3.9/contextlib.py", line 119, in __enter__
return next(self.gen)
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceAzure.py", line 319, in temporary_hostname
previous_hostname = get_hostname(hostname_command)
File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceAzure.py", line 302, in get_hostname
return subp.subp(hostname_command, capture=True)[0].strip()
File "/usr/lib/python3.9/site-packages/cloudinit/subp.py", line 264, in subp
raise ProcessExecutionError(
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ('hostname',)
Exit code: -
Reason: [Errno 2] No such file or directory: b'hostname'
Stdout: -
Stderr: -
------------------------------------------------------------
```
Comment by David Runge (dvzrv) - Saturday, 19 February 2022, 20:13 GMT
@patrakov: Is this still an issue with cloud-init 22.1?
Comment by Alexander E. Patrakov (patrakov) - Saturday, 19 February 2022, 20:16 GMT
I have not checked, but https://github.com/canonical/cloud-init/pull/1143/files removed the use of "hostname" from this place. I will try the latest qcow2 file on my private Azure account today or tomorrow. Thanks for the reminder.
Comment by Alexander E. Patrakov (patrakov) - Sunday, 20 February 2022, 01:03 GMT
@dvzrv I cannot answer your question today, because the latest available pre-built cloud image, https://mirror.pkgbuild.com/images/v20220215.47946/Arch-Linux-x86_64-cloudimg-20220215.47946.qcow2, still includes cloud-init v. 21.4, which has the issue. Please remind me when a new cloud image with a recent-enough cloud-init is produced (perhaps as a result of a GitLab CI job).
Comment by Alexander E. Patrakov (patrakov) - Sunday, 20 February 2022, 01:07 GMT
https://gitlab.archlinux.org/archlinux/arch-boxes/-/jobs/48065 looks like a job that produced the image that I asked for, but alas, the artifacts were removed 19 hours ago, and there is no new successful build.
Comment by David Runge (dvzrv) - Sunday, 20 February 2022, 11:21 GMT
I think they might be built daily actually and the release happens every week or bi-weekly I think.
Comment by Alexander E. Patrakov (patrakov) - Monday, 21 February 2022, 22:42 GMT
Now we have a new qcow2 image produced by ci/cd that contains a recent-enough version of cloud-init:

https://gitlab.archlinux.org/archlinux/arch-boxes/-/jobs/48463/artifacts/file/output/Arch-Linux-x86_64-cloudimg-20220220.48463.qcow2

I confirm that it works on Azure unmodified (other than format-conversion via qemu-img).
Comment by David Runge (dvzrv) - Tuesday, 22 February 2022, 08:02 GMT
@patrakov: Excellent, thanks!

Loading...