Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ds-identify doesn't look in /usr/local/etc/cloud/ but only in /etc/cloud/ [FreeBSD] #4481

Closed
dch opened this issue Oct 2, 2023 · 5 comments
Labels
bug Something isn't working correctly

Comments

@dch
Copy link

dch commented Oct 2, 2023

Bug report

ds-identify doesn't look in /usr/local/etc/cloud/ but only in
/etc/cloud/, which is in conflict with all the other cloud-init
tools on FreeBSD, and probably the other BSDs.

In particular, ds-identify looks in /etc/cloud/cloud.cfg to find
things like datasource_list: ... but these files live in
/usr/local/etc/cloud/... on FreeBSD, and possibly other BSDs.

This then likely breaks cloudinit for anybody using a non-OpenStack
config, as the DataSource will be overridden.

Steps to reproduce the problem

  • FreeBSD 13.2-RELEASE, although logs below come from 14.x
  • cloudinit v23.3 from latest ports branch
  • run using env DI_LOG=stderr /usr/local/lib/cloud/ds-identify --force
  • identified datasource should be Ec2 but is OpenStack
  • edit ds-identify script to use PATH_ETC_CLOUD="/usr/local/etc/cloud"
  • re-run and datasource is Ec2 again

default
with path hack

# /usr/local/etc/cloud/cloud.cfg
syslog_fix_perms: root:wheel
disable_root: false
preserve_hostname: false
ssh_deletekeys: false
network: {config: disabled}
datasource_list: ['Ec2']
phone_home:
    url: http://...
    post:
    - instance_id
    tries: 5
datasource:
    Ec2:
        strict_id: false
        timeout: 60
        max_wait: 120
        metadata_urls:
         - https://...
        dsmode: net
cloud_init_modules:
    - migrator
    - ssh
cloud_final_modules:
    - phone-home
    - scripts-user
    - ssh-authkey-fingerprints
    - keys-to-console
    - final-message
system_info:
    distro: freebsd

Environment details

  • Cloud-init version: v23.3
  • Operating System Distribution: FreeBSD 13.2-RELEASE
  • Cloud provider, platform or installer type: from source

logs without /etc/cloud/ds-identify.cfg

root@metal:~ # env DI_LOG=stderr /usr/local/lib/cloud-init/ds-identify --force
[up unavailables] ds-identify --force
policy loaded: mode=search report=false found=all maybe=all notfound=enabled
no datasource_list found, using default: MAAS ConfigDrive NoCloud AltCloud Azure Bigstep CloudSigma CloudStack DigitalOcean Vultr AliYun Ec2 GCE OpenNebula OpenStack OVF SmartOS Scaleway Hetzner IBMCloud Oracle Exoscale RbxCloud UpCloud VMware LXD NWCS Akamai
DMI_PRODUCT_NAME=SYS-510T-MR-EI018
DMI_SYS_VENDOR=Supermicro
DMI_PRODUCT_SERIAL=S482931X2814219
DMI_PRODUCT_UUID=3ac39800-6cff-11ec-8000-3cecefc84871
PID_1_PRODUCT_NAME=
DMI_CHASSIS_ASSET_TAG=To be filled by O.E.M.
DMI_BOARD_NAME=X12STH-SYS
FS_LABELS=efiboot,biosboot,swapspace,root
ISO9660_DEVS=
KERNEL_CMDLINE=unavailable:no-cmdline
VIRT=none
UNAME_KERNEL_NAME=FreeBSD
UNAME_KERNEL_RELEASE=14.0-BETA4
UNAME_KERNEL_VERSION=FreeBSD 14.0-BETA4 #0 releng/14.0-n265159-ced511bd972a: Fri Sep 29 06:08:27 UTC 2023
[email protected]:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
UNAME_NODENAME=metal.af
UNAME_OPERATING_SYSTEM=amd64
DSNAME=
DSLIST=MAAS ConfigDrive NoCloud AltCloud Azure Bigstep CloudSigma CloudStack DigitalOcean Vultr AliYun Ec2 GCE OpenNebula OpenStack OVF SmartOS Scaleway Hetzner IBMCloud Oracle Exoscale RbxCloud UpCloud VMware LXD NWCS Akamai
MODE=search
ON_FOUND=all
ON_MAYBE=all
ON_NOTFOUND=enabled
pid=25078 ppid=24804
is_container=false
is_ds_enabled(IBMCloud) = true.
ec2 platform is 'Unknown'.
is_ds_enabled(IBMCloud) = true.
check for 'OpenStack' returned maybe
1 datasources returned maybe: OpenStack
[up unavailables] returning 0
  • defaults to OpenStack
  • picks wrong metadata server & IP
2023-10-02 22:01:30,933 - url_helper.py[ERROR]: Timed out, no response from urls: ['http://[fe80::a9fe:a9fe]/openstack', 'http://169.254.169.254/openstack']
@dch dch added bug Something isn't working correctly new An issue that still needs triage labels Oct 2, 2023
@dch
Copy link
Author

dch commented Oct 2, 2023

I think patching PATH_DI_CONFIG=/etc/cloud/ds-identify.cfg is the simplest change.

@igalic
Copy link
Collaborator

igalic commented Oct 2, 2023

yes, but also, this is related to #4180

to generalise: unlike the python code, we currently have no method of relocating paths in our shell code.

(not that I've dared to try and relocate /run in the python code yet to /var/run. at least the tools exist already. but i can't tell how consistently they are used until i try to do it)

@dch
Copy link
Author

dch commented Oct 3, 2023

Then perhaps judicious use of %%LOCALBASE%% and %%PREFIX%% in the port may be the best approach, at leeast initially.

@dch
Copy link
Author

dch commented Oct 4, 2023

see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274260 for work-around for FreeBSD ports.

igalic added a commit to igalic/cloud-init that referenced this issue Oct 4, 2023
override PATH_DI_CONFIG and PATH_ETC_CLOUD when executing ds-identify \
on startup.

Inconviniently, we can't just override PATH_ROOT, because that would set
/run to /usr/local/run and /var/lib/cloud to /usr/local/var/lib/cloud.

In the future we will want to override /run, but we can't do that just
yet without also ensuring that the python code can relocate /run.

Fixes: canonicalGH-4481
Sponsored by: The FreeBSD Foundation
@igalic
Copy link
Collaborator

igalic commented Oct 4, 2023

here's my attempt at fixing it: #4485

igalic added a commit to igalic/cloud-init that referenced this issue Oct 4, 2023
override PATH_DI_CONFIG and PATH_ETC_CLOUD when executing ds-identify \
on startup.

Inconviniently, we can't just override PATH_ROOT, because that would set
/run to /usr/local/run and /var/lib/cloud to /usr/local/var/lib/cloud.

In the future we will want to override /run, but we can't do that just
yet without also ensuring that the python code can relocate /run.

Fixes: canonicalGH-4481
Sponsored by: The FreeBSD Foundation
@aciba90 aciba90 removed the new An issue that still needs triage label Oct 5, 2023
igalic added a commit to igalic/cloud-init that referenced this issue Oct 6, 2023
override PATH_DI_CONFIG and PATH_ETC_CLOUD when executing ds-identify \
on startup.

Inconviniently, we can't just override PATH_ROOT, because that would set
/run to /usr/local/run and /var/lib/cloud to /usr/local/var/lib/cloud.

In the future we will want to override /run, but we can't do that just
yet without also ensuring that the python code can relocate /run.

Fixes: canonicalGH-4481
Sponsored by: The FreeBSD Foundation
igalic added a commit to igalic/cloud-init that referenced this issue Oct 6, 2023
override PATH_DI_CONFIG and PATH_ETC_CLOUD when executing ds-identify \
on startup.

Inconviniently, we can't just override PATH_ROOT, because that would set
/run to /usr/local/run and /var/lib/cloud to /usr/local/var/lib/cloud.

In the future we will want to override /run, but we can't do that just
yet without also ensuring that the python code can relocate /run.

Fixes: canonicalGH-4481
Sponsored by: The FreeBSD Foundation
Co-authored-by: Dave Cottlehuber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

3 participants