cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
428 stars 151 forks source link

Network Config v2 parser requires nameservers to be set #156

Open FlorianLaunay opened 1 month ago

FlorianLaunay commented 1 month ago

I have found an issue in the Network Config v2 parser that requires nameservers to be set : cloudbaseinit/metadata/services/nocloudservice.py#L335.

Here is the error log when nameservers is not set:

2024-09-30 13:32:19.818 768 INFO cloudbaseinit.init [-] Executing plugin 'NetworkConfigPlugin'
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init [-] plugin 'NetworkConfigPlugin' failed with error ''NoneType' object has no attribute 'get''
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init [-] 'NoneType' object has no attribute 'get': AttributeError: 'NoneType' object has no attribute 'get'
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init Traceback (most recent call last):
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\init.py", line 66, in _exec_plugin    
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     (status, reboot_required) = plugin.execute(service,
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init                                 ^^^^^^^^^^^^^^^^^^^^^^^
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\plugins\common\networkconfig.py", line 305, in execute
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     network_details = service.get_network_details_v2()
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\vmwareguestinfoservice.py", line 165, in get_network_details_v2
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     return nocloudservice.NoCloudNetworkConfigParser.parse(network)
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\nocloudservice.py", line 548, in parse
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     return network_config_parser.parse(network_data)
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\nocloudservice.py", line 515, in parse
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     self._get_network_config_parser(singular)
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\nocloudservice.py", line 376, in _parse_ethernet_config_item
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     networks, services = self._parse_addresses(item, link.name)
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init   File "C:\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Lib\site-packages\cloudbaseinit\metadata\services\nocloudservice.py", line 338, in _parse_addresses
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init     searches = nameservers.get("search", [])
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init                ^^^^^^^^^^^^^^^
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init AttributeError: 'NoneType' object has no attribute 'get'
2024-09-30 13:32:19.818 768 ERROR cloudbaseinit.init

I think this argument should be set to an empty value by default.

FlorianLaunay commented 1 month ago

I have opened a change to fix this issue : https://review.opendev.org/c/x/cloudbase-init/+/930923

FlorianLaunay commented 1 month ago

I have also opened a PR : #157

seanmorton commented 1 month ago

I just hit this bug as well, thanks @FlorianLaunay!

ader1990 commented 4 weeks ago

Hello, was waiting for a new release of the https://pypi.org/project/sphinx-rtd-theme/3.0.0/ to unblock the gates.

Will merge https://review.opendev.org/c/x/cloudbase-init/+/930923 asap, thanks!