canonical / canonical/cloud-init
Traceback when there is no OpenStack data source
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 22
Description
# Bug report
The ds-identify script guesses that we may be in an OpenStack environment on non x86_64 architectures, in this case aarch 64 [1]. This then triggers the enablement of cloud-init services and as such the execution of the Python code. When no data source if found by the OpenStack data source implementation an exception trickles to the top causing a traceback.
```
2024-04-05 14:34:22,076 - util.py[DEBUG]: No active metadata service found
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/cloudinit/sources/DataSourceOpenStack.py", line 158, in _get_data
results = util.log_time(
^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/cloudinit/util.py", line 2833, in log_time
ret = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/cloudinit/sources/DataSourceOpenStack.py", line 212, in _crawl_metadata
raise sources.InvalidMetaDataException(
cloudinit.sources.InvalidMetaDataException: No active metadata service found
```
and
```
2024-04-05 14:34:22,107 - util.py[DEBUG]: failed stage init-local
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/cloudinit/cmd/main.py", line 385, in main_init
init.fetch(existing=existing)
File "/usr/lib/python3.11/site-packages/cloudinit/stages.py", line 466, in fetch
return self._get_data_source(existing=existing)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/cloudinit/stages.py", line 357, in _get_data_source
(ds, dsname) = sources.find_source(
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/cloudinit/sources/__init__.py", line 1032, in find_source
raise DataSourceNotFoundException(msg)
cloudinit.sources.DataSourceNotFoundException: Did not find any data source, searched classes: (DataSourceOpenStackLocal)
```
The exception should be handled and no traceback should be generated.
[1] https://github.com/canonical/cloud-init/blob/main/tools/ds-identify#L1370
## Steps to reproduce the problem
Run a VM on aarch64 with cloud-init default config and no config drive.
## Environment details
- Cloud-init version: 23.3
- Operating System Distribution: SL Micro
- Cloud provider, platform or installer type: Not running in a cloud enviroment
## cloud-init logs
[cloud-init.tar.gz](https://github.com/canonical/cloud-init/files/14887299/cloud-init.tar.gz)
Contributor guide
Research direction
Start in cloudinit/sources/DataSourceOpenStack.py at _get_data and _crawl_metadata, then follow how the exception reaches cloudinit/stages.py and cloudinit/sources/__init__.py during init-local. Reproduce the aarch64 or no-data-source case and verify that the failed OpenStack probe completes without a traceback while normal data-source discovery still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100