canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
2.97k stars 880 forks source link

Azure data source assumes network is driven via dhcpclient #3451

Open ubuntu-server-builder opened 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1845252

Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2019-09-24T20:16:02.686593+00:00
date_fix_committed = None
date_fix_released = None
id = 1845252
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1845252
milestone = None
owner = rjschwei
owner_name = Robert Schweikert
private = False
status = triaged
submitter = rjschwei
submitter_name = Robert Schweikert
tags = []
duplicates = []

Launchpad user Robert Schweikert(rjschwei) wrote on 2019-09-24T20:16:02.686593+00:00

The Azure data source assumes that the network is set up by dhcpclient. During cloud-init initialization the following traceback is generated:

Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/cloudinit/sources/DataSourceAzure.py", line 668, in _negotiate fabric_data = metadata_func() File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(*args, kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 458, in get_metadata_from_fabric return shim.register_with_azure_and_fetch_data(pubkey_info=pubkey_info) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(*args, *kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 393, in register_with_azure_and_fetch_data 'http://{0}/machine/?comp=goalstate'.format(self.endpoint)) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 272, in endpoint self.dhcpoptions) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(args, kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 374, in find_endpoint fallback_lease_file) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(*args, **kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 300, in _get_value_from_leases_file content = util.load_file(fallback_lease_file) File "/usr/lib/python3.6/site-packages/cloudinit/util.py", line 1359, in load_file with open(fname, 'rb') as ifh: FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/dhcp/dhclient.eth0.leases'

ubuntu-server-builder commented 1 year ago

Launchpad user Robert Schweikert(rjschwei) wrote on 2019-09-24T20:18:24.765285+00:00

Launchpad attachments: cloud-init.log

ubuntu-server-builder commented 1 year ago

Launchpad user Robert Schweikert(rjschwei) wrote on 2019-09-24T21:08:43.272815+00:00

On SUSE the option of interest is in /var/lib/wicked/lease-eth0-dhcp-ipv4.xml

ubuntu-server-builder commented 1 year ago

Launchpad user Robert Schweikert(rjschwei) wrote on 2019-09-25T13:22:05.241982+00:00

This happens with 19.1, i.e. the current SUSE package. In master the code in question is wrapped with a try: except: block that avoids the traceback

def _get_value_from_leases_file(fallback_lease_file): leases = [] try: content = util.load_file(fallback_lease_file) except IOError as ex: LOG.error("Failed to read %s: %s", fallback_lease_file, ex) return None

Adding this to 19.1 leads to:

2019-09-25 13:03:35,101 - DataSourceAzure.py[WARNING]: Error communicating with Azure fabric; You may experience.connectivity issues. Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/cloudinit/sources/DataSourceAzure.py", line 668, in _negotiate fabric_data = metadata_func() File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(*args, kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 462, in get_metadata_from_fabric return shim.register_with_azure_and_fetch_data(pubkey_info=pubkey_info) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(*args, *kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 397, in register_with_azure_and_fetch_data 'http://{0}/machine/?comp=goalstate'.format(self.endpoint)) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 272, in endpoint self.dhcpoptions) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 36, in impl return func(args, kwargs) File "/usr/lib/python3.6/site-packages/cloudinit/sources/helpers/azure.py", line 381, in find_endpoint raise ValueError('No endpoint found.') ValueError: No endpoint found.

I am going to stop digging at this point.