Skip to content

CloudStack Datasource Fails to find Default Gateway on FreeBSD due to no proc filesystem #4191

@loth

Description

@loth

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 <class 'cloudinit.distros.freebsd.Distro'>
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 <class 'cloudinit.sources.DataSourceCloudStack.DataSourceCloudStack'>
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 <class 'cloudinit.sources.DataSourceCloudStack.DataSourceCloudStack'> failed
2023-06-20 14:29:06,527 - util.py[DEBUG]: Getting data from <class 'cloudinit.sources.DataSourceCloudStack.DataSourceCloudStack'> 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctlyincompleteAction required by submitter

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions