cloudbase / cloudbase-init

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

add retries for get_network_adapter_name_by_mac_address #47

Open noliaoliao opened 4 years ago

noliaoliao commented 4 years ago

for my testes, sometimes cloudbase-init can't initialize interface correctly, and lookup the log we can see the exception as below

2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init [-] plugin 'NetworkConfigPlugin' failed with error 'Network interface with MAC address "24:6e:96:27:d4:38" not found': cloudbaseinit.exception.ItemNotFoundException: Network interface with MAC address "24:6e:96:27:d4:38" not found
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init [-] Network interface with MAC address "24:6e:96:27:d4:38" not found: cloudbaseinit.exception.ItemNotFoundException: Network interface with MAC address "24:6e:96:27:d4:38" not found
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init Traceback (most recent call last):
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\init.py", line 67, in _exec_plugin
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init     shared_data)
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\networkconfig.py", line 307, in execute
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init     return self._process_network_details_v2(network_details)
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\networkconfig.py", line 296, in _process_network_details_v2
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init     osutils, network_details)
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\networkconfig.py", line 198, in _process_physical_links
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init     link.mac_address)
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init   File "c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\osutils\windows.py", line 752, in get_network_adapter_name_by_mac_address
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init     mac_address)
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init cloudbaseinit.exception.ItemNotFoundException: Network interface with MAC address "24:6e:96:27:d4:38" not found
2020-05-22 14:03:21.273 2968 ERROR cloudbaseinit.init 

I guess this is because when cloud-init run, the NICs are don't seen by OS, so we should add more retries here, just like this commint https://github.com/cloudbase/cloudbase-init/commit/41161e5d571898f8d4b0af132d01559716e00d81

ader1990 commented 4 years ago

Hello @noliaoliao ,

If your system is slow (I assume it is baremetal), I suggest you to set the cloudbase-init service to automatic delayed start, to make sure this kind of issues does not happen.