Public bug reported:
cloud-init version: 0.7.9-90-g61eb03fe-0ubuntu1~16.04.1
Ubuntu version: 16.04 LTS
On a pristine install cloud-init fails in every stage on startup with
the following error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 647, in
status_wrapper
ret = functor(name, args)
File "/usr/lib/python3/dist-packages/cloudinit/cmd/main.py", line 350, in
main_init
init.apply_network_config(bring_up=not args.local)
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 648, in
apply_network_config
return self.distro.apply_network_config(netcfg, bring_up=bring_up)
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line
163, in apply_network_config
dev_names = self._write_network_config(netconfig)
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 89,
in _write_network_config
return self._supported_write_network_config(netconfig)
File "/usr/lib/python3/dist-packages/cloudinit/distros/__init__.py", line 82,
in _supported_write_network_config
renderer.render_network_config(network_config=network_config)
File "/usr/lib/python3/dist-packages/cloudinit/net/renderer.py", line 47, in
render_network_config
network_state=parse_net_config_data(network_config), target=target)
File "/usr/lib/python3/dist-packages/cloudinit/net/eni.py", line 446, in
render_network_state
util.write_file(fpeni, header + self._render_interfaces(network_state))
File "/usr/lib/python3/dist-packages/cloudinit/net/eni.py", line 403, in
_render_interfaces
for iface in network_state.iter_interfaces():
AttributeError: 'NoneType' object has no attribute 'iter_interfaces'
This leads to the instance not being provisioned at all.
Looking through the code the following change seems to be the origin:
https://github.com/cloud-init/cloud-
init/commit/ef18b8ac4cf7e3dfd98830fbdb298380a192a0fc#diff-
4542b4dbbb95a6fa664e1030691a1809R40
At this point there is a check if both 'version' and 'config' are True.
By default no network config is set and the 'net_config' parameter
passed here in 'parse_net_config_data' is '{'config': [], 'version':
1}'. With 'config' being an empty list it evaluates to False therefore
skipping the parsing and just returning None. The rendering step never
bothers to check for None and just assumes the passed config to be
valid.
Suggested fix:
1. Change the check of 'config' to explicitly test for None (if version and
config is not None) which would restore the intended semantics of parsing the
empty list (and therefore returning the empty NetworkState).
2. Add an explicit check to the renderer(s) to check if the network_state is
None and skip the rendering in this case (maybe emit a warning).
I could prepare a fix if you let me know where and how to submit a PR.
** Affects: cloud-init (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1686338
Title:
cloud-init fails if no network config is set
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1686338/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs