Network config is incorrectly parsed when nameservers are specified
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Invalid
|
Undecided
|
Unassigned | ||
cloud-init (Suse) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
The issue was reproduced on Azure with cloud-init 19.1 on a SLES12 SP4 machine. Looking at the code, the same behavior could be reproduced on any other configuration where the cloud provider specifies nameservers in the network configuration.
The specified nameservers in network configuration are ignored and cloud-init raises an error.
In network_state.py the function _v2_common builds a name_cmd dictionary which is then passed to the function handle_nameserver. The handle_nameserver has a decorator that enforces that passed in dictionary to have the key "address". But the _v2_common build a dictionary that has the key "addresses" instead. That results in raising an error.
Here's a snapshot of the cloud-init.log
2019-09-09 16:21:29,479 - network_
{'search': 'xkf00b0rtzgejk
2019-09-09 16:21:29,479 - network_
Traceback (most recent call last):
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
required_keys))
InvalidCommand: Command missing set(['address']) of required keys ['address']
Thanks for the bug and the logs. Looking at the network-config that was generated:
>>> print(yaml.dump(nc, default_ flow_style= False, indent=4))
macaddress : 00:0d:3a:6d:ca:25
ethernets:
eth0:
dhcp4: true
match:
set-name: eth0
nameservers:
addresses: 168.63.129.16
search: xkf00b0rtzgejk
The bug is that nameservers needs to be indented *under* eth0.
However, cloud-init upstream does not parse or process nameservers[1] from Azure metadata, so I can't understand why you have this bug unless the cloud-init 19.1 on SLES has some downstream patches.
1. https:/ /git.launchpad. net/cloud- init/tree/ cloudinit/ sources/ DataSourceAzure .py#n1305