canonical / canonical/cloud-init
CloudStack Datasource Fails to find Default Gateway on FreeBSD due to no proc filesystem
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 22
Description
# Bug report
When falling back to obtaining the default gateway using the cloudstack datasource we obtain a exception from cloud-init due to it looking for /proc/net/route and freebsd does not use the /proc filesystem
## Steps to reproduce the problem
Create VM, make sure no leases are existing so it falls back to default GW
## Environment details
- Cloud-init version: 23.1.1
- Operating System Distribution: FreeBSD 13.2
- Cloud provider, platform or installer type:
## cloud-init logs
```
2023-06-20 14:29:06,491 - stages.py[DEBUG]: Using distro class
2023-06-20 14:29:06,491 - subp.py[DEBUG]: Running command ['ifconfig', '-a'] with allowed return codes [0] (shell=False, capture=True)
2023-06-20 14:29:06,497 - __init__.py[DEBUG]: Looking for data source in: ['CloudStack'], via packages ['', 'cloudinit.sources'] that matches dependencies ['FILESYSTEM', 'NETWORK']
2023-06-20 14:29:06,501 - __init__.py[DEBUG]: Searching for network data source in: ['DataSourceCloudStack']
2023-06-20 14:29:06,501 - handlers.py[DEBUG]: start: init-network/search-CloudStack: searching for network data from DataSourceCloudStack
2023-06-20 14:29:06,501 - __init__.py[DEBUG]: Seeing if we can get any data from
2023-06-20 14:29:06,526 - DataSourceCloudStack.py[DEBUG]: DNS Entry data-server not found
2023-06-20 14:29:06,527 - DataSourceCloudStack.py[DEBUG]: No lease file found, using default gateway
2023-06-20 14:29:06,527 - util.py[DEBUG]: Reading from /proc/net/route (quiet=False)
2023-06-20 14:29:06,527 - handlers.py[DEBUG]: finish: init-network/search-CloudStack: FAIL: no network data found from DataSourceCloudStack
2023-06-20 14:29:06,527 - util.py[WARNING]: Getting data from failed
2023-06-20 14:29:06,527 - util.py[DEBUG]: Getting data from failed
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/cloudinit/sources/__init__.py", line 975, in find_source
s = cls(sys_cfg, distro, paths)
File "/usr/local/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudStack.py", line 90, in __init__
self.vr_addr = get_vr_address()
File "/usr/local/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudStack.py", line 283, in get_vr_address
return get_default_gateway()
File "/usr/local/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudStack.py", line 199, in get_default_gateway
lines = util.load_file("/proc/net/route").splitlines()
File "/usr/local/lib/python3.9/site-packages/cloudinit/util.py", line 1539, in load_file
with open(fname, "rb") as ifh:
FileNotFoundError: [Errno 2] No such file or directory: '/proc/net/route'
2023-06-20 14:29:06,534 - util.py[WARNING]: No instance datasource found! Likely bad things to come!
2023-06-20 14:29:06,534 - util.py[DEBUG]: No instance datasource found! Likely bad things to come!
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/cloudinit/cmd/main.py", line 385, in main_init
init.fetch(existing=existing)
File "/usr/local/lib/python3.9/site-packages/cloudinit/stages.py", line 434, in fetch
return self._get_data_source(existing=existing)
File "/usr/local/lib/python3.9/site-packages/cloudinit/stages.py", line 325, in _get_data_source
(ds, dsname) = sources.find_source(
File "/usr/local/lib/python3.9/site-packages/cloudinit/sources/__init__.py", line 987, in find_source
raise DataSourceNotFoundException(msg)
cloudinit.sources.DataSourceNotFoundException: Did not find any data source, searched classes: (DataSourceCloudStack)
```
Contributor guide
Research direction
Start in cloudinit/sources/DataSourceCloudStack.py at get_default_gateway(), called by get_vr_address(). Reproduce the CloudStack fallback on FreeBSD 13.2 with no lease file and inspect how the default gateway is obtained when /proc/net/route is absent. Done means the datasource can find the gateway and continue initialization on FreeBSD; add or update tests if the existing datasource test structure covers this path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100