NoCloud data source not working on FreeBSD platform

Bug #1819871 reported by sammohung76 on 2019-03-13
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
High
Unassigned

Bug Description

The NoCloud data source appears to not correctly search for available seed devices on FreeBSD.

=== Original Report ===

Platform: FreeBSD 11.2-RELEASE amd64, FreeBSD 12.0-RELEASE amd64
cloud-init 18.3 from official ports tree: https://www.freshports.org/net/cloud-init/

seed sample:

network-config:
--
version: 1
config:
    - type: physical
      name: enp0s4
      subnets:
      - type: static
        address: 172.17.0.98/24
        gateway: 172.17.0.98
    - type: nameserver
      address:
      - 8.8.8.8
      search:
      - my.domain

meta-data:
--
instance-id: cloud2-fbsd-01
local-hostname: cloud2-fbsd-01.mycloud.com

guest cloud.cfg settings:

..
system_info:
..
distro: freebsd
..

at cloudinitlocal startup i see:

..
running command ['blkid', '-odevice', '/dev/sr0'] with allowed return codes [0, 2] (
..

cloud-init for some reason doesn't recognize distro settings and try to use Linux-specific command ('glabel' or 'gpart show' for FreeBSD should be used).

Also, when media found, further work leads to:

--
init.py[WARNING]: apply_network_config is not currently implemented for distribution '<class 'cloudinit.distros.freebsd.Distro'>'. Attempting to use apply_network
--

user-data also ignored.

I know that you are not interested in supporting FreeBSD on your own, but why do you hinder the community from improving your product? There are patches to support FreeBSD from different people. Therefore, this issue is also called “feature request” to support FreeBSD. Some large cloud / hosting organizations provide their clients with the FreeBSD platform.

Dan Watkins (daniel-thewatkins) wrote :

Hi,

Thanks for using cloud-init, and thanks for filing this bug! I'm sorry that you've been having issues running cloud-init on FreeBSD. Could you run `cloud-init collect-logs` as root on a system where you're seeing these issues and attach the created tarball here, please? Once done, please set the bug back to New.

(As for the patches: I only see one bug with a patch in a search for "freebsd", and the person who contributed it unfortunately doesn't appear to have signed the CLA to allow us to incorporate it. If there are others, could you please direct us to them?)

Thanks!

Dan

Changed in cloud-init:
status: New → Incomplete
sammohung76 (sammohung76) wrote :

Dan, thanks for the reaction!

It seems that I was mistaken about cloud-init third-party patches for FreeBSD: I got confused because of the presence of this port: https://www.freshports.org/net/cloud-init-azure/

But, as it is written, it is supported by a person from Microsoft so this is not an ordinary person ;-).

In any case, these ports contain a patch that seems to work for the cloud-initialization of FreeBSD in the Azure cloud:

https://svnweb.freebsd.org/ports/head/net/cloud-init-azure/files/patch-frbsd-azure.txt?revision=441117&view=markup

as for the standard cloud-init port ( (which I mentioned in first message ), I attach the logs that you ask.

sammohung76 (sammohung76) wrote :

cloud-init collect-logs for latest cloud-init on FreeBSD

sammohung76 (sammohung76) wrote :

judging by the attempt to use Linux-only command: ( 'dpkg' instead of 'pkg', 'journalctl', 'blkid' instead of 'glabel status -s' ), totally misunderstood that it works on FreeBSD.

My local storage at the moment attached as cd9660:

% glabel status -s
gptid/a7dee359-48f6-11e9-9507-00a0985f4f17 N/A vtbd0p1
                            msdosfs/EFISYS N/A vtbd0p1
                            iso9660/cidata N/A cd1

Dan Watkins (daniel-thewatkins) wrote :

Thanks for the logs! I've filed https://bugs.launchpad.net/cloud-init/+bug/1820609 to capture the collect-logs package manager issue.

It looks to me like a lot of those changes were submitted and merged in https://code.launchpad.net/~redriver/cloud-init/+git/cloud-init/+merge/314895 so they should be present in cloud-init now.

Could you confirm how you're launching this instance, and what cloud environment it is running in?

sammohung76 (sammohung76) wrote :

Latest version in the FreeBSD ports: 18.3 ( with local patchest: https://svnweb.freebsd.org/ports/head/net/cloud-init/files/ ) << btw, maybe there is a chance to add it to upstream?

Im also try latest cloud-init release from https://launchpad.net/cloud-init (18.5) but no luck.

I talked to some people who use cloud-init on FreeBSD on Azure and OpenStack cloud. No one seems to have problems, because in these clouds information is received through HTTP and all fine. I seem to be the first person on the planet who tried cloud-init with local storages.

as for the rest of the questions:

I do not use ready-made FreeBSD cloud instance ( despite the fact that the project also makes them: http://ftp.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/12.0-RELEASE/amd64/Latest/ ). I need to create my own image, so i can write how to reproduce environment from the scratch:

1) download latest official FreeBSD release:

wget https://download.freebsd.org/ftp/releases/amd64/amd64/ISO-IMAGES/12.0/FreeBSD-12.0-RELEASE-amd64-disc1.iso

2) run it in any hypervisor ( personally i run in bhyve but it doesn't matter ) and install as usual

3) restart guest domain after install with proper seed.iso

4) inside guest: change pkg repository from quarterly to latest:

    sed -i'' 's:quarterly:latest:g' /etc/pkg/FreeBSD.conf

5) install cloud-init:

     pkg update -f
     pkg install -y net/cloud-init

6) try to run cloudinit[local]

despite the fact that 'cidata' exist on media via ( glabel status -s ), cloud-init doesn't use it.

ps: unfortunately i'm not familiar with the cloud-init code. But if anything - I am ready to help solve the problem ( testing, consultations on FreeBSD commands so on )

Dan Watkins (daniel-thewatkins) wrote :

Thanks for the info! It sounds like this is specifically an issue with the NoCloud data source, so I'm going to update the bug title and description.

If someone did want to pick this up, it sounds like you'd want to start looking at the NoCloud data source (https://github.com/cloud-init/cloud-init/blob/master/cloudinit/sources/DataSourceNoCloud.py#L100). Specifically, the code from lines 100 to 136, where a seed device is searched for; I suspect at least some of the util.* functions there are missing FreeBSD support.

Please do feel free to email the cloud-init mailing list or drop in to #cloud-init on freenode if you have any questions!

(N.B. code submissions go in through https://code.launchpad.net/cloud-init, not GH.)

summary: - cloud-init 18.3 not working on FreeBSD platform
+ NoCloud data source not working on FreeBSD platform
description: updated
Changed in cloud-init:
status: Incomplete → Triaged
importance: Undecided → Medium
importance: Medium → High
Gonéri Le Bouder (goneri) wrote :

Hi, sammohung76. this branch https://github.com/goneri/cloud-init/tree/freebsd comes with tree patches that improve the situation. The network change still WIP and I will rebase it until it's ready for review. Could you give them a try?

To use the freebsd network renderer, you need to edit /usr/local/etc/cloud/cloud.cfg and change the system_info section:

system_info:
   distro: freebsd
# Add these two lines
   network:
     renderers: ['freebsd']

I already opened this merge request: https://code.launchpad.net/~goneri/cloud-init/+git/cloud-init/+merge/364997

Dan Watkins (daniel-thewatkins) wrote :

Aha, will mark this as a duplicate of the bug that MP resolves.

sammohung76 (sammohung76) wrote :

@goneri, I created Makefile for FreeBSD ports https://pastebin.com/p1Y5NGzg which points to your repository ( for more convenient testing ).

Unfortunately cidata storage still not determined by cloud-init:

glabel status -s
gptid/4a827d3c-56b7-11e9-a07c-00a0989c11ae N/A vtbd0p1
                            msdosfs/EFISYS N/A vtbd0p1
                            iso9660/cidata N/A cd1

I attached logs for you.

sammohung76 (sammohung76) wrote :
sammohung76 (sammohung76) wrote :

@goneri FYI, utils.py in cloud-init-output.log still print:

 util.py[WARNING]: Unable to determine distribution, template expansion may have unexpected results

despite /usr/local/etc/cloud/cloud.cfg:
..
system_info:
   # This will affect which distro class gets used
   distro: freebsd
   # Default user name + that default users groups (if added/used)
...

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers