Bug 1787232

Summary: IgnitionHandler overwrites files in passed JSON when VM Hostname is present
Product: [oVirt] ovirt-engine Reporter: David Alger <davidmalger>
Component: Backend.CoreAssignee: Liran Rotenberg <lrotenbe>
Status: CLOSED DUPLICATE QA Contact: meital avital <mavital>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.3.7.2CC: bugs, michal.skrivanek, rbarry
Target Milestone: ovirt-4.4.1Flags: pm-rhel: ovirt-4.4+
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-01-08 16:18:22 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Alger 2020-01-01 19:28:21 UTC
Description of problem:

When using CloudInit with a Custom Script to pass Ignition config and the VM Hostname is specified (as it is by default) "files" (or possibly "storage") is overwritten by the logic added to IgnitionHandler in https://gerrit.ovirt.org/#/c/100397/ preventing use of Ignition to configure files on the VM.

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

oVirt Node 4.3.7.2-1.el7

How reproducible: Occurs 100% of the time; workaround (clear VM Hostname field when using CloudInit with Custom Script) is possible.


Steps to Reproduce:
1. Import "Fedora CoreOS 30.20190801.0" from ovirt-image-repository as a template.
2. Create a new virtual machine from the template created in step #1; configure options as follows:
3. Under Initial Run, enable "Use Cloud-Init/Sysprep" and ensure VM Hostname is specified (it should be filled by default based on the virtual machine name)
4. Pass a Custom Script (such as the following) which contains a file to be placed on the machine during the initial startup (replace public key with one of your own).


{"ignition":{"config":{"replace":{"source":null,"verification":{}}},"security":{"tls":{}},"timeouts":{},"version":"3.0.0"},"passwd":{"users":[{"name":"core","sshAuthorizedKeys":["ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4UTV2t+5Ze6JDiU7Ws9SLKUrh8oq+3lkAIXsx54w8bW8huk4TViqALb4PgYTWwH9eRFUjBzx/9dxTZMrkUPCeHRWxoKmUONTYaH8xz5vGcCbSw/qC/BVXZ6TofRB7vkFWOMDgq8Y57pN/kq7k8cvMUNWqZ+My/k1HPpZLBTHiSDaGb3AU1lXEyPzu0rCHbPeuJcRhIbixhbxTL9RgiKYDcz1UXoklqCnFVC2wP0Hd9LjxASZGJQYdjqHm2bnnEL9ztHDxnY2/9/kRDzXw3wEALDhJQq8/M5xiB9Ul3FVpm2qCqu7NKxZxzM8iH0fyKUz0CZ0pmqkfXSqaYhyH65FdQ=="]}]},"storage":{"files":[{"group":{},"path":"/etc/example-file.txt","user":{},"contents":{"source":"data:,Hello%20world!","verification":{}},"mode":420}]},"systemd":{}}


5. Initial Run configuration should end up looking something like this:
https://dropshare-ot3kdw.s3.amazonaws.com/uLum9y/Screen-Shot-2020-01-01-12-06-43.23-NwFsbkbWhmhQ.png


Actual results:

/etc/example-file.txt is not placed on the host and is missing from the Ignition config found on the config-2 disk.

Expected results:

$ cat /etc/example-file.txt; echo
Hello world!



Additional info:


Once the machine has been created, connect to the virtual machine via SSH and inspect the Ignition configuration passed to the machine by the ovirt-engine:


> Fedora 30.20190801.0 (CoreOS preview)
> Tracker: https://github.com/coreos/fedora-coreos-tracker
> Preview release: breaking changes may occur
> 
> Last login: Wed Jan  1 18:07:48 2020 from 172.16.0.133
> [core@coreos-gu3viv ~]$ sudo mkdir /tmp/ignition-config
> [core@coreos-gu3viv ~]$ sudo mount -o ro -t auto /dev/disk/by-label/config-2 /tmp/ignition-config
> [core@coreos-gu3viv ~]$ sudo cat /tmp/ignition-config/openstack/latest/user_data && echo
> {"ignition":{"config":{"replace":{"source":null,"verification":{}}},"security":{"tls":{}},"timeouts":{},> "version":"3.0.0"},"passwd":{"users":[{"name":"core","sshAuthorizedKeys":["ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4UTV2t> +5Ze6JDiU7Ws9SLKUrh8oq+3lkAIXsx54w8bW8huk4TViqALb4PgYTWwH9eRFUjBzx/9dxTZMrkUPCeHRWxoKmUONTYaH8xz5vGcCbSw/qC/> BVXZ6TofRB7vkFWOMDgq8Y57pN/kq7k8cvMUNWqZ+My/> k1HPpZLBTHiSDaGb3AU1lXEyPzu0rCHbPeuJcRhIbixhbxTL9RgiKYDcz1UXoklqCnFVC2wP0Hd9LjxASZGJQYdjqHm2bnnEL9ztHDxnY2/9/> kRDzXw3wEALDhJQq8/M5xiB9Ul3FVpm2qCqu7NKxZxzM8iH0fyKUz0CZ0pmqkfXSqaYhyH65FdQ=="]}]},"storage":{"files":[> {"filesystem":"root","path":"/etc/hostname","mode":420,"contents":{"source":"data:,coreos-gu3viv"}}]},"systemd":{}}
> [core@coreos-gu3viv ~]$ sudo umount /tmp/ignition-config
> [core@coreos-gu3viv ~]$ cat /etc/example-file.txt; echo
> cat: /etc/example-file.txt: No such file or directory
> 
> [core@coreos-gu3viv ~]$ logout
> Connection to 172.16.0.184 closed.


Note that the files section (possibly entire storage section) of the JSON passed as the Custom Script (see above) has been completely replaced by the output of org.ovirt.engine.core.vdsbroker.vdsbroker.IgnitionHandler.hostnameIgnitionSnippet() causing the /etc/example-file.txt to not be written by Ignition config as would normally be expected.

This is the result of the work done at https://gerrit.ovirt.org/#/c/100397/ to support specifying the hostname field when an Ignition config is used during the intial run. See this for the relevant (and faulty) logic: https://gerrit.ovirt.org/#/c/100397/2/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/IgnitionHandler.java

Comment 1 RHEL Program Management 2020-01-02 10:14:33 UTC
The documentation text flag should only be set after 'doc text' field is provided. Please provide the documentation text and set the flag to '?' again.

Comment 2 Liran Rotenberg 2020-01-08 16:18:22 UTC
Hi David,
Thanks for the report!

This bug is fixed in the RFE to add the RHCOS(bz 1726907).

*** This bug has been marked as a duplicate of bug 1726907 ***