It doesn't seem to be caused by a race between networkd and NetworkManager.
I reproduced the issue with qemu here and I see the name resolution failure happening few seconds before NetworkManager started.
From /var/log/cloud-init.log:
2023-03-09 19:17:58,443 - util.py[DEBUG]: Getting data from <class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloudNet'> failed
Traceback (most recent call last):
...
cloudinit.url_helper.UrlError: HTTPConnectionPool(host='boot.linuxgroove.com', port=80): Max retries exceeded with url: /ubuntu/23.04/meta-data (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f650b663610>:
Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
From systemd's journal
Mar 09 19:18:01 ubuntu systemd[1]: Starting NetworkManager.service - Network Manager...
(edit)
resolved wasn't running as well
2023-03-09T19:18:01.712656+00:00 ubuntu systemd[1]: Starting systemd-resolved.service - Network Name Resolution...
It doesn't seem to be caused by a race between networkd and NetworkManager.
I reproduced the issue with qemu here and I see the name resolution failure happening few seconds before NetworkManager started.
From /var/log/ cloud-init. log:
2023-03-09 19:17:58,443 - util.py[DEBUG]: Getting data from <class 'cloudinit. sources. DataSourceNoClo ud.DataSourceNo CloudNet' > failed url_helper. UrlError: HTTPConnectionP ool(host= 'boot.linuxgroo ve.com' , port=80): Max retries exceeded with url: /ubuntu/ 23.04/meta- data (Caused by NewConnectionEr ror('<urllib3. connection. HTTPConnection object at 0x7f650b663610>:
Traceback (most recent call last):
...
cloudinit.
Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
From systemd's journal service - Network Manager...
Mar 09 19:18:01 ubuntu systemd[1]: Starting NetworkManager.
(edit)
resolved wasn't running as well
2023-03- 09T19:18: 01.712656+ 00:00 ubuntu systemd[1]: Starting systemd- resolved. service - Network Name Resolution...
but it seems my instance had a nameserver:
2023-03-09 19:17:58,500 - stages.py[INFO]: Applying network configuration from initramfs bringup=True: {'config': [{'type': 'physical', 'name': 'ens3', 'subnets': [{'type': 'dhcp', 'control': 'manual', 'netmask': '255.255.255.0', 'broadc 00:12:34: 56'}], 'version': 1}
ast': '10.0.2.255', 'gateway': '10.0.2.2', 'dns_nameservers': ['10.0.2.3']}], 'mac_address': '52:54: