I tried to recreate the issue, and everything works as expected. (Except for that dumb “LXD VM agent isn’t currently running” error – should just be a warning and I wrote code to explicitly ignore that error). Anyway, I’m going to close this out. But, for anyone who may following along, I did capture CLI variant of the processing. Most likely, TL;DR, but for posterity.
A lot of this is, again, based on the fact that BOSH sits on top of some cloud infrastructure. In this case, LXD.
Generate an ISO image: (genisoimage
happened to be pre-installed on Ubuntu, so I used it.)
$ genisoimage -o config.iso -V config-2 isocontents/
I: -input-charset not specified, using utf-8 (detected in locale settings)
Total translation table size: 0
Total rockridge attributes bytes: 0
Total directory bytes: 112
Path table size(bytes): 10
Max brk space used 0
175 extents written (0 MB)
Downloaded the current openstack stemcell (aka image) from bosh.io and extracted the QEMU image; renamed to rootfs.img
since I think LXD expects that name.
$ tar xOzf ~/Downloads/bosh-stemcell-1.531-openstack-kvm-ubuntu-jammy-go_agent.tgz image | tar xzf -
$ file root.img
root.img: QEMU QCOW Image (v2), 5368709120 bytes (v2), 5368709120 bytes
$ mv root.img rootfs.img
Upload the image – create metadata.yaml
tarball.
$ cat > metadata.yaml << EOF
architecture: x86_64
creation_date: 1725555591
properties:
architecture: x86_64
description: bosh-openstack-kvm-ubuntu-jammy-go_agent
os: linux
root_device_name: /
root_disk_size: 5120MiB
EOF
$ tar czf metadata.tgz metadata.yaml
$ lxc image import metadata.tgz rootfs.img
Image imported with fingerprint: 2334a0463f0ec22e6292d54c99d5a84cd388e4b76f3f5d84801a4034331a2ac3
Create the VM (note we need the BIOS since BOSH does not use a UEFI boot).
$ lxc init 2334a0463f0e boshvm --vm --type c2-m4 --config raw.qemu="-bios bios-256k.bin"
Creating boshvm
Import the ISO image created earlier.
$ lxc storage volume import default config.iso config-2
$ lxc storage volume list
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| POOL | TYPE | NAME | DESCRIPTION | CONTENT-TYPE | USED BY |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| default | custom | config-2 | | iso | 0 |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| default | image | 2334a0463f0ec22e6292d54c99d5a84cd388e4b76f3f5d84801a4034331a2ac3 | | block | 1 |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| default | virtual-machine | boshvm | | block | 1 |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
This is where I expected things to start to deviate…
First, I just attached, detached, and then removed without starting the VM:
# Good case - unused
$ lxc config device add boshvm config-2 disk pool=default source=config-2
Device config-2 added to boshvm
$ lxc config device list boshvm
config-2
$ lxc config device remove boshvm config-2
Device config-2 removed from boshvm
Then I did the same but launched the VM. To be certain it saw everything somewhat as expected (it’s a fake config cdrom, after all), I made certain that the agent process was finding the labeled disk (config-2
) and was mounting and then unmounting it:
# Expecting this to be the bad case - device is temporarily used and the lock remains...
$ lxc config device add boshvm config-2 disk pool=default source=config-2
Device config-2 added to boshvm
$ lxc start boshvm
$ lxc console boshvm
<boots...>
<disk gets mounted/unmounted as agent tries to get configuration>
/:~$ mount -l | grep config-2
<empty, so not currently mounted, looking at logs for evidence of the mount...>
<piece of logs from /var/vcap/bosh/log/current>
2024-09-05_17:27:35.92516 ********************
2024-09-05_17:27:35.92516 [Cmd Runner] 2024/09/05 17:27:35 DEBUG - Running command 'mount /dev/disk/by-label/config-2 /tmp/diskutil1195713740'
2024-09-05_17:27:35.92516 [DelayedAuditLogger] 2024/09/05 17:27:35 DEBUG - Starting logging to syslog...
2024-09-05_17:27:35.94255 [Cmd Runner] 2024/09/05 17:27:35 DEBUG - Stdout:
2024-09-05_17:27:35.94261 [Cmd Runner] 2024/09/05 17:27:35 DEBUG - Stderr: mount: /tmp/diskutil1195713740: WARNING: source write-protected, mounted read-only.
2024-09-05_17:27:35.94267 [Cmd Runner] 2024/09/05 17:27:35 DEBUG - Successful: true (0)
2024-09-05_17:27:35.94270 [diskUtil] 2024/09/05 17:27:35 DEBUG - Mounted disk path '/dev/disk/by-label/config-2' to '/tmp/diskutil1195713740'
2024-09-05_17:27:35.94304 [diskUtil] 2024/09/05 17:27:35 DEBUG - Reading contents of '/tmp/diskutil1195713740/ec2/latest/user-data'
2024-09-05_17:27:35.94308 [File System] 2024/09/05 17:27:35 DEBUG - Reading file /tmp/diskutil1195713740/ec2/latest/user-data
2024-09-05_17:27:35.94480 [diskUtil] 2024/09/05 17:27:35 DEBUG - Unmounting disk path '/tmp/diskutil1195713740'
2024-09-05_17:27:35.94484 [File System] 2024/09/05 17:27:35 DEBUG - Reading file /proc/mounts
2024-09-05_17:27:35.94487 [File System] 2024/09/05 17:27:35 DEBUG - Read content
2024-09-05_17:27:35.94488 ********************
<logout>
<back on the desktop>
$ lxc config device remove boshvm config-2
Error: LXD VM agent isn't currently running
$ lxc config device list boshvm
# ^^ empty
$ lxc storage volume list
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| POOL | TYPE | NAME | DESCRIPTION | CONTENT-TYPE | USED BY |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| default | custom | config-2 | | iso | 0 | <== NOT IN USE
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| default | image | 2334a0463f0ec22e6292d54c99d5a84cd388e4b76f3f5d84801a4034331a2ac3 | | block | 1 |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
| default | virtual-machine | boshvm | | block | 1 |
+---------+-----------------+------------------------------------------------------------------+-------------+--------------+---------+
$ lxc storage volume rm default config-2
Storage volume config-2 deleted
# ^^ This is where I expected it to fail.
As you can see, it worked as expected. Uncertain if I “fixed” something along the way, or if I’m too slow as a human, or the fact that it’ not a real configuration (as in the disk gets mounted/unmounted that quickly).
Thanks for checking in!