Some additional information:
- Problem observed with Openstack Ussuri and Victoria.
- This problem is observed with Ubuntu VM with one interface in the external openstack network.
- During the creation of the VM the cloud-init can not request VM related metadata from source "http://169.254.169.254/openstack". This leads to timeout and initialization with default keys. Startup LOG indicates: "WARNING not metadata source"
A workarround is to perform a "hard boot" of the VM. During "hard boot" the log file "/var/log/cloud-init.log" indicates that a route is added that seems to fix the problem. See log entry 14:27:08,314 below that is at the biginning of the "hard boot". The 10.20.34.100 is an IP within the external network, that provides the metadata.
ubuntu@external-server:/var/log$ grep "169.254.169.254" cloud-init.log
2022-01-06 14:25:33,037 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 0.000 seconds
2022-01-06 14:25:33,037 - url_helper.py[DEBUG]: [0/1] open 'http://169.254.169.254/openstack' with {'url': 'http://169.254.169.254/openstack', 'allow_redirects': True, 'method': 'GET', 'timeout': 10.0, 'headers': {'User-Agent': 'Cloud-Init/21.4-0ubuntu1~20.04.1'}} configuration
2022-01-06 14:25:43,050 - url_helper.py[DEBUG]: Calling 'http://169.254.169.254/openstack' failed [10/-1s]: request error [HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /openstack (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fa3b80d8a60>, 'Connection to 169.254.169.254 timed out. (connect timeout=10.0)'))]
2022-01-06 14:25:43,050 - DataSourceOpenStack.py[DEBUG]: Giving up on OpenStack md from ['http://169.254.169.254/openstack'] after 10 seconds
2022-01-06 14:25:54,772 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 10.014 seconds
2022-01-06 14:25:54,772 - url_helper.py[DEBUG]: [0/1] open 'http://169.254.169.254/openstack' with {'url': 'http://169.254.169.254/openstack', 'allow_redirects': True, 'method': 'GET', 'timeout': 10.0, 'headers': {'User-Agent': 'Cloud-Init/21.4-0ubuntu1~20.04.1'}} configuration
2022-01-06 14:26:04,785 - url_helper.py[DEBUG]: Calling 'http://169.254.169.254/openstack' failed [10/-1s]: request error [HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /openstack (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7fdefd568700>, 'Connection to 169.254.169.254 timed out. (connect timeout=10.0)'))]
2022-01-06 14:26:04,785 - DataSourceOpenStack.py[DEBUG]: Giving up on OpenStack md from ['http://169.254.169.254/openstack'] after 10 seconds
2022-01-06 14:27:08,314 - subp.py[DEBUG]: Running command ['ip', '-4', 'route', 'add', '169.254.169.254/32', 'via', '10.20.34.100', 'dev', 'ens3'] with allowed return codes [0] (shell=False, capture=True)
2022-01-06 14:27:08,317 - util.py[DEBUG]: Resolving URL: http://169.254.169.254 took 0.000 seconds
2022-01-06 14:27:08,318 - url_helper.py[DEBUG]: [0/1] open 'http://169.254.169.254/openstack' with {'url': 'http://169.254.169.254/openstack', 'allow_redirects': True, 'method': 'GET', 'timeout': 10.0, 'headers': {'User-Agent': 'Cloud-Init/21.4-0ubuntu1~20.04.1'}} configuration
2022-01-06 14:27:08,930 - url_helper.py[DEBUG]: Read from http://169.254.169.254/openstack (200, 105b) after 1 attempts
2022-01-06 14:27:08,930 - DataSourceOpenStack.py[DEBUG]: Using metadata source: 'http://169.254.169.254'
2022-01-06 14:27:08,930 - url_helper.py[DEBUG]: [0/6] open 'http://169.254.169.254/openstack' with {'url': 'http://169.254.169.254/openstack', 'allow_redirects': True, 'method': 'GET', 'timeout': 10.0, 'headers': {'User-Agent': 'Cloud-Init/21.4-0ubuntu1~20.04.1'}} configuration
2
After the reboot the SSH access is possible with configured credentials.
Problem could be the cloud-init script, that is not adding the route to metadata server during first cloud_init of the VM.