canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.87k stars 854 forks source link

network-manager renderer not properly configuring /etc/resolv.conf #4097

Open ubuntu-server-builder opened 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #2015494

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2023-04-06T15:54:39.018777+00:00
date_fix_committed = None
date_fix_released = None
id = 2015494
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/2015494
milestone = None
owner = rosario-esposito
owner_name = olaszfiu
private = False
status = triaged
submitter = rosario-esposito
submitter_name = olaszfiu
tags = []
duplicates = []

Launchpad user olaszfiu(rosario-esposito) wrote on 2023-04-06T15:54:39.018777+00:00

I'm running cloud-init 23.1.1 on a rockylinux 9 virtual machine (running on Proxmox VE) with network-manager renderer.

The cloud-init network-config file is:

version: 1 config:

Inside the VM base image I have, in /etc/cloud/cloud.cfg:

system_info: network: renderers: ['network-manager'] activators: ['network-manager']

When I start the VM, everything works fine and the renderer creates the correct NIC config file: /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection:

Generated by cloud-init. Changes will be lost.

[connection] id=cloud-init eth0 uuid=1dd9a779-d327-56e1-8454-c65e2556c12c type=ethernet

[user] org.freedesktop.NetworkManager.origin=cloud-init

[ethernet] mac-address=62:04:02:7B:34:A0

[ipv4] method=manual may-fail=false address1=172.18.7.1/23 gateway=172.18.7.254

The problem is that /etc/resolv.conf is not correctly configured with my DNS servers:

cat /etc/resolv.conf

Generated by NetworkManager

search na.infn.it

Digging into /usr/lib/python3.9/site-packages/cloudinit/net/network_manager.py it seems to me that networ-manager renderer only adds DNS servers if specified in NIC configuration (i.e. in a "subnets" section of the yaml network-config file). Those specified under "type: nameserver" get ignored.

Not sure if this is a bug or it's the expected behavior. Could you please clarify ?

Thanks

ubuntu-server-builder commented 1 year ago

Launchpad user Alberto Contreras(aciba) wrote on 2023-04-10T15:09:13.152518+00:00

Thanks olaszfiu for reporting this.

Global DNS configuration especied in network config v1 under "type: nameserver" is effectively not rendered by the network-manager renderer and it should be.

For reference, these are some related bugs for other renderers:

The solution will probably consist on attaching the DNS to every given interface (like in the referenced bug) as NetworkManager does not have the concept of global DNS config (I think).