Azure: IMDS service not retried on timeout

Bug #1800223 reported by Chad Smith on 2018-10-26
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

cloud-init 18.4-7-g4652b196-0ubuntu1 on Azure does not retry IMDS if the service is not yet available.

Per configuration in the azure datasource, it should retry 4 times before failing, but logs only list one attempt at

We can see this in the following excerpt of /var/log/cloud-init.log

2018-10-26 17:26:51,162 -[DEBUG]: [0/4] open '' with {'url': '', 'allow_redirects': True, 'method': 'GET', 'timeout': 1.0, 'headers': {'User-Agent': 'Cloud-Init/18.4-7-g4652b196-0ubuntu1', 'Metadata': 'true'}} configuration
2018-10-26 17:26:52,168 -[DEBUG]: Ignoring IMDS instance metadata: HTTPConnectionPool(host='', port=80): Max retries exceeded with url: /metadata/instance?api-version=2017-12-01 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f392a7c5668>, 'Connection to timed out. (connect timeout=1.0)'))
2018-10-26 17:26:52,168 -[DEBUG]: Crawl of Azure Instance Metadata Service (IMDS) took 1.007 seconds

Only 1 attempt (out of 4) was attempted and then Azure datasource gave up after receiving a ConnectTimeoutError.

At a later time on the instance, I was able to see that the IMDS service was available using the following python script:

$ python3 -c 'from cloudinit.sources.DataSourceAzure import get_metadata_from_imds; print(get_metadata_from_imds("eth0", retries=2))';

{'compute': {'location': 'eastus2', 'name': 'my-c1', 'offer': 'UbuntuServer', 'osType': 'Linux', 'placementGroupId': '', 'platformFaultDomain': '0', 'platformUpdateDomain': '0', 'publisher': 'Canonical', 'resourceGroupName': 'srugroup1', 'sku': '18.10-DAILY', 'subscriptionId': '12aad61c-6de4-4e53-a6c6-5aff52a83777', 'tags': '', 'version': '18.10.201810230', 'vmId': 'ec22ac8c-f728-425f-852f-5b86d0c9f2f7', 'vmScaleSetName': '', 'vmSize': 'Standard_DS1_v2', 'zone': ''}, 'network': {'interface': [{'ipv4': {'ipAddress': [{'privateIpAddress': '', 'publicIpAddress': ''}], 'subnet': [{'address': '', 'prefix': '24'}]}, 'ipv6': {'ipAddress': []}, 'macAddress': '000D3A03582B'}]}}

Related branches

Chad Smith (chad.smith) wrote :

Released in cloud-init v18.4-22-g6062595b-0ubuntu1. Currently avaialable in Ubuntu Disco series.

Changed in cloud-init:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers