dermotbradley/create-alpine-disk-image

Building with `--experimental` and `--release edge` is broken due to `cloud-init` and `ptp`

Closed this issue · 3 comments

Building with both --experimental and --release edge generates an invalid create.sh script:

The NTP section ends up like:

	ntp:
	  enabled: True
	  hypervisor_clock: True
	    device: $_ptp_device
	    dpoll: $_ptp_dpoll
	    poll: $_ptp_poll
	    offset: "$_ptp_offset"
	    stratum: $_ptp_stratum

There are actually 2 bugs here:

  1. cat <<'EOF' >> "$run_script" should be cat <<EOF >> "$run_script"
  2. The 4 lines above it need to have $ added after the :- otherwise it just puts CONSTANT_DEFAULT_... in the file

However, even after fixing this, there are other bugs.

The script wants to use /dev/ptp_kvm, but this doesn't exist on v3.17 or edge, it seems to just be /dev/ptp0 now (on proxmox at least).

But also, enabling it causes cloud-init to fail to work at all with the following error:

------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/cloudinit/cmd/main.py", line 767, in status_wrapper
    ret = functor(name, args)
          ^^^^^^^^^^^^^^^^^^^
  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 434, in fetch
    return self._get_data_source(existing=existing)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cloudinit/stages.py", line 327, in _get_data_source
    self.distro,
    ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cloudinit/stages.py", line 135, in distro
    distro_cls = distros.fetch(distro_name)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/cloudinit/distros/__init__.py", line 1241, in fetch
    raise ImportError(
ImportError: No distribution found for distro ubuntu (searched ['ubuntu', 'cloudinit.distros.ubuntu'])
------------------------------------------------------------

This seems to be the result of specifying 2 layers of invalid config.

I get similar of I add:

ntp:
  enabled: True
  foo: bar
    baz: qux

A single layer of invalid config just gives a nice error:

2023-03-12 03:57:51,170 - schema.py[WARNING]: Invalid cloud-config provided: Please run 'sudo cloud-init schema --system' to see the schema errors.

I also can't find any mention of the hypervisor_clock setting that it's trying to set anywhere: https://github.com/search?q=repo%3Acanonical%2Fcloud-init+hypervisor_clock&type=code

Hi there

Unfortunately it has been some time since I updated this Github repo (7 months or so) and so the version here is behind with quite a few fixes and changes (there's lots of additional functionality added to my local version).

The "--experimental" option enables some stuff that is still work-in-progress and this PTP related stuff is one of them.

This is functionality that I have been working on for cloud-init that will be submitted upstream shortly (which is why you found no mention of it), I'm testing locally with a modified cloud-init package.

I've now hidden the PTP stuff behind an addition cli option (rather than just "--experimental).

The script wants to use /dev/ptp_kvm, but this doesn't exist on v3.17 or edge, it seems to just be /dev/ptp0 now (on proxmox at least).

That is strange as I submitted the changes to the Alpine mdev package for /dev/ptp_kvm and those changes are in Alpine 3.17 and Edge. From your mention of /dev/ptp0 I guess you are looking on Proxmox host itself rather than inside the VM? /dev/ptp_kvm should appear in the Alpine VM (as long as the ptp_kvm kernel module is loaded) as KVM (which Proxmox uses) provides this to VMs for performing timesync with the host machine.

Regarding this problem and your 2 PRs, I will be concentrating on this script this week and intend to update this repo shortly, that will then address all 3 issues.

Hey

Thanks for the response, wasn't sure if you had been actively working on it in the background or not and thanks for explaining about the cloud-init stuff.

This is definitely inside the image, and only the /dev/ptp0 exists:

alpine [~]# echo 'Kernel:'; uname -a; echo 'Version:'; cat /etc/alpine-release; echo 'Modules:'; lsmod | grep -i ptp; echo 'Devices:'; ls -l /dev | grep -i ptp;
Kernel:
Linux alpine 5.15.101-0-virt #1-Alpine SMP Sun, 12 Mar 2023 13:50:37 +0000 x86_64 GNU/Linux
Version:
3.17.2
Modules:
ptp_kvm                16384  0
Devices:
crw------- 1 root root 249,   0 Mar 13 04:40 ptp0
alpine [~]#

I've not really looked too much more into it, but it seemed like 3.16 had it, then 3.17 and edge did not, and chrony seemed perfectly happy using the /dev/ptp0 device. I figured this was an intentional change to standardise on a common device name rather than per-module device names.

I look forward to the updated version of the repo, I'll hold off on any other issues/PRs until that drops.

Sorry about the long delay, a minor change turned into a major rework.

Anyway new version has been pushed.