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

Fixes #13778 - Libvirt cloud-init provisioning fails #3205

Closed
wants to merge 1 commit into from

Conversation

dLobatog
Copy link
Member

When you try to boot a VM with libvirt and cloud-init provisioning,
libvirt will make a initial .iso file to be provided during the VM
booting process.
This .iso file is created wherever the main volume for the VM is
created (storage-pool-path/cloud-init-data.iso).

Fog-libvirt sets iso_dir for all VMs to '/var/lib/libvirt/images'
as the default location to fetch the cloud-init .iso.
Foreman will try to use this directory when creating the VM as the
location for cloud-init.
However, that may not be right if the storage-pool is not the
default one. In my case, I run my libvirt VMs from an external
hard-drive, so Foreman needs to understand the iso_dir will be the
external hard-drive storage pool, not the default
/var/lib/libvirt/images.

Fix is simple, just set iso_dir during the VM creation process.

When you try to boot a VM with libvirt and cloud-init provisioning,
libvirt will make a initial .iso file to be provided during the VM
booting process.
This .iso file is created wherever the main volume for the VM is
created (storage-pool-path/cloud-init-data.iso).

Fog-libvirt sets iso_dir for all VMs to '/var/lib/libvirt/images'
as the default location to fetch the cloud-init .iso.
Foreman will try to use this directory when creating the VM as the
location for cloud-init.
However, that may not be right if the storage-pool is not the
default one. In my case, I run my libvirt VMs from an external
hard-drive, so Foreman needs to understand the iso_dir will be the
external hard-drive storage pool, not the default
/var/lib/libvirt/images.

Fix is simple, just set iso_dir during the VM creation process.
@dLobatog
Copy link
Member Author

Marking this as 1.11 as we shouldn't be releasing with broken cloud-init

@@ -124,6 +124,7 @@ def new_vm(attr = { })
def create_vm(args = { })
vm = new_vm(args)
create_volumes :prefix => vm.name, :volumes => vm.volumes, :backing_id => args[:image_id]
vm.iso_dir = vm.volumes.first.path.split('/')[0..-2].join('/')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the volume is in a directory storage pool, but it could be something like /dev/lvmvg/lvmlv. I think it probably needs to do two things differently:

  1. Check the pool associated with the volume has type == 'dir', and if not, perhaps find another volume that does, or pick the first pool that does(?).
  2. Use the path out of the pool rather than parsing it from the volume path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think I take back point one. It looks like the cloud-init disk that fog-libvirt generates is always going to be uploaded into the pool called "default" (due to upload_image).

If so, then there's probably no direct relation between the pool of the first volume and the ISO image's pool, and this code should be setting iso_dir to the default pool's path? (This rather looks like a bug in fog-libvirt to me, not Foreman.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hit this today too, so filed fog/fog-libvirt#20.

@dLobatog
Copy link
Member Author

Closing in favor of fog/fog-libvirt#20, thanks @domcleal

@dLobatog dLobatog closed this Mar 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants