nocloud-net not working in cloud-init >=23.4
Bug report
I noticed that the nocloud-net datasource isn't working in 23.4.3. If I set a seed via dmi, my http server never sees requests from cloud-init. The same setup works fine with 23.3.1. nocloud works fine in 23.4.3.
git bisect reports a commit first released in 23.4:
76b7b381497af9e4a6197606fd4d5fd5269b180b is the first bad commit
commit 76b7b381497af9e4a6197606fd4d5fd5269b180b
Author: Chris Patterson <[email protected]>
Date: Tue Sep 12 10:51:14 2023 -0400
sources: do not override datasource detection if None is in list (#4426)
Users with datasource_list = [Azure, None] started failing to boot
properly outside of Azure with the changes to override datasource detection.
If the fallback "None" is included in the datasource_list, do not treat
the system as configured with a single datasource.
If users want to force a single datasource regardless of detection,
they can do so by removing None from the list.
Signed-off-by: Chris Patterson <[email protected]>
cloudinit/sources/__init__.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
I wasn't able to test main with this reverted due to some test failures. But the logs reveal that override_ds_detect is returning False. In the working 23.3.1 case, the logs have this:
$ grep single cloud-init.log
2024-02-19 21:11:03,359 - __init__.py[DEBUG]: Machine is configured to run on single datasource DataSourceNoCloud [seed=None][dsmode=net].
2024-02-19 21:11:05,392 - __init__.py[DEBUG]: Machine is configured to run on single datasource DataSourceNoCloudNet [seed=None][dsmode=net].
But it's gone in 23.4.3.
Steps to reproduce the problem
- Start a webserver to serve a seed, nothing specific is required
- Boot a qemu vm pointing to that server:
-smbios type=1,serial=ds='nocloud;s=http://10.0.2.2:8000/'(nocloudvsnocloud-netmakes no difference) - no requests are seen on the webserver, cloud-init uses
DataSourceNone
Environment details
- Cloud-init version: 23.4.3, current main (
89ebcc394) - Operating System Distribution: debian sid
- Cloud provider, platform or installer type: qemu
cloud-init logs
logs from current main are attached.
@rvandegrift What does cat /sys/class/dmi/id/product_serial show in the booted instance?
Something like ds=nocloud;s=http://10.0.2.2:8000/ I would assume?
If so, something like this branch is probably what I would propose as a fix.
I'm also affected by the issue. Suddenly installations with cloud-init are failing with the following error:
DataSourceNoCloud.py[DEBUG]: See from http://my-cloud-init-url/ not supported by DataSourceNoCloud [seed=None][dsmode=net]
The serial is defined as following:
<sysinfo type='smbios'>
<system>
<entry name='serial'>ds=nocloud-net;s=http://my-cloud-init-url/cloud-init/</entry>
</system>
</sysinfo>
OS: Ubuntu 18.04 LTS, 20.04 LTS, 22.04 LTS
I can also confirm that downgrading the cloud-init package to 22.1-4 resolves the issue. This is really a deal breaker. That bug affects literally all cloud-init contextualisations I do.
@thannaske thanks for confirming this issue
This is being treated as a high priority issue and will be fixed in the next release. We expect to start the release process early next week, once the fix (see related PR) lands.
@thannaske @rvandegrift @OnitiFR Thanks for reporting this issue, and thanks @rvandegrift for reviewing the proposed fix.
We plan on landing the fix (with an integration test so that this never happens again) this morning if possible, and starting the SRU release today. Once we've done that it will be in the hands of SRU reviewers to get the fix included in the Ubuntu repositories, though you could add our proposed PPA or build from source (or just keep downgrading cloud-init).
An alternative workaround is using qemu's -append flag with your ds=nocloud;... content. This may require specifying the kernel with -kernel and the initrd with -initrd. This obviously requires manually getting the kernel and initrd files, but if you have an image to boot, it should be possible to mount the image locally to grab those files. This workaround is somewhat intensive, but maybe it helps somebody.
Appreciate your efforts, thank you. Unfortunately, the -append workaround isn't really feasible for us right now because it would affect a (very) large number of servers with hundreds of different operating systems and kernel version combinations.
We for now can only hope that the nocloud DMI/serial functionality is working again, soon. We may look into providing our own Datasource to eliminate the reliance on the generic datasource once and for all; until now we just didn't see the use case for developing one.
We for now can only hope that the nocloud DMI/serial functionality is working again, soon.
We will keep adding updates to this issue.
We may look into providing our own Datasource to eliminate the reliance on the generic datasource once and for all; until now we just didn't see the use case for developing one.
Sounds good
Also, if testing cloud-init's proposed releases would be of value to you, that can be accomplished on test systems by enabling the -proposed repository from Ubuntu main and updating cloud-init. If a release is queued (like this fix will be soon), then your instance will get an updated cloud-init. Early testing feedback is always welcome.
The fix for this issue was resolved in the https://github.com/canonical/cloud-init/pull/4949 which landed in https://github.com/canonical/cloud-init/commit/66b5ce9d5f94c0c6625972fdfdca3796d365b069 and released as cloud-init version 23.4.4 . It is currently uploaded to the -proposed pocket for verification in Ubuntu Focal, Jammy and Mantic (and has already been uploaded to Ubuntu Noble). Expectation is that this will release within the next week to Ubuntu cloud-images.
For anyone out there interested: the current (20240301) clould images use cloud-init 23.4.4 and now boots correctly!
Thanks to everyone involved in this fix! ❤️
For anyone out there interested: the current (20240301) clould images use cloud-init 23.4.4 and now boots correctly!
Thanks to everyone involved in this fix! ❤️
fyi @thannaske @rvandegrift