Bug 1448231

Summary: cfme not passing cloud init payload to vm's
Product: Red Hat CloudForms Management Engine Reporter: luke couzens <lcouzens>
Component: ProvidersAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Ilanit Stein <istein>
Severity: high Docs Contact:
Priority: unspecified    
Version: 5.8.0CC: abellott, cpelland, dajohnso, istein, jfrey, jhardy, juan.hernandez, lcouzens, obarenbo, simaishi
Target Milestone: GAKeywords: Regression, TestOnly
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: cloud_init
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1448863 (view as bug list) Environment:
Last Closed: 2018-03-06 14:57:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: RHEVM Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1427603, 1448863    

Description luke couzens 2017-05-04 21:36:04 UTC
Description of problem:cfme not passing cloud init payload to vm's


Version-Release number of selected component (if applicable):5.8.0.13


How reproducible:100%


Steps to Reproduce:
1.provision appliance
2.add cloud init script to infra-PXE-customization templates
3.add rhevm provider
4.provision new vm with cloud init script

Actual results:script does not run on startup of vm


Expected results:script runs successfully


Additional info:
script I used:
#cloud-config
write_files:
  - path: /tmp/test.txt
    content: |
      Here is a line.

I ran this against a cfme build on rhevm provider which failed, running this against the same template directly on rhevm works as expected.

This last worked on 5.8.0.11

Comment 3 Ilanit Stein 2017-05-05 14:52:41 UTC
This might be related to bug 1427603.

Comment 4 Juan Hernández 2017-05-05 20:10:56 UTC
I checked this again with the latest version of the 'fine' branch and in my opinion it works correctly.

Can you please check the following in RHV?

1. Make sure that the template uses has the value Linux (or some variant of Linux) in the General -> Operating System field.

2. Make sure that the template has Initial Run -> Use Cloud-Init/Sysprep checked.

3. Start the VM from CFME, and when it is running in RHV, edit it and check that your custom script appears in Initial Run -> Custom Script.

4. Go to the RHV hypervisor where the VM is running (with SSH) and find the corresponding qemu-kvm process:

  ps -ef | grep qemu-kvm | grep the_name_of_the_vm

That long command line should contain an option pointing to the 'payload', something like this:

  -drive file=/var/run/vdsm/payload/ae3a9cd4-....img

Copy that .img file somewhere, and then mount it:

  # mount -o loop,ro that_file.img /mnt

Then explore the content:

  # find /mnt -type f
  /mnt/openstack/content/0000
  /mnt/openstack/latest/meta_data.json
  /mnt/openstack/latest/user_data

The 'openstack/latest/user_data' file should contain the cloud-init
ocnfiguration that CFME sent to RHV. Does it look correct? Does it contain your custom script?

We also need to know the version of RHV that you are using.

Comment 5 Juan Hernández 2017-05-06 10:40:41 UTC
After studying this with more detail I realized that the payload is correctly passed from CFME to RHV, but then CFME starts the virtual machine without the 'use_cloud_init' parameter. That means that the payload won't actually be used by RHV, even if it is there. I can confirm that this is a regression introduced by the recent changes in the fine branch to implement provisioning with versions 3 or 4 of the RHV API.

The proposed pull request to fix this issue is the following:

  Handle blocks when using `method_missing`
  https://github.com/ManageIQ/manageiq-providers-ovirt/pull/30

The provider has been separated to a new git repository right after the creation of the 'fine' branch, so an explicit backport will be needed for that branch. This is the pull request:

  [FINE] Handle blocks when using `method_missing` in oVirt
  https://github.com/ManageIQ/manageiq/pull/15021

Comment 7 Ilanit Stein 2017-12-18 14:55:37 UTC
Verified on CFME-5.9.0.12/RHV-4.1.8.

* Template for provision:
using CFME-5.9.0.11 Template (OS type:RHEL-7),  cloud-init 0.7.9.

* Customization Template:
Using CFME: Compute->Infrastructure->PXE: 
Customization Template (Image Type:	RHEL-6, Type:CloudInit),
with content:
write_files:
- path: "/tmp/test.txt"
  content: Here is a line.

Test flow:
On CFME, run VM provision from Template (CFME-5.9.0.11), Native,
in the Customize tab choose the above customization template.

Test results:
Script was passed to RHV side: In Edit VM dialog:
Use cloud init option is checked, 
and custom script contain the above Customization Template content.
Also File /tmp/test.txt was created, with: "Here is a line." content.