Bug 2209897

Summary: Cloud-init userdata is not parsed correctly if "userData" string is removed
Product: Container Native Virtualization (CNV) Reporter: nijin ashok <nashok>
Component: User ExperienceAssignee: Ugo Palatucci <upalatuc>
Status: CLOSED MIGRATED QA Contact: Guohua Ouyang <gouyang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.13.0CC: gouyang, ycui
Target Milestone: ---   
Target Release: 4.14.0   
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: 2023-08-22 11:14:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description nijin ashok 2023-05-25 07:47:29 UTC
Description of problem:

From the console, while creating VM using the template, customize virtual machine => scripts => Edit cloudinit => Click checkbox script => remove everything and add only a customer value like "example: test" and save and apply.

Now when we edit the cloud int again to see the configuration, the data will be below:

~~~
userData: |
  #cloud-config
  '0': u
  '1': 'n'
  '2': d
  '3': e
  '4': f
  '5': i
  '6': 'n'
  '7': e
  '8': d
~~~



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

OpenShift Virtualization   4.13.0

How reproducible:

100%

Steps to Reproduce:

Please refer above.

Actual results:

Cloud-init user data is not parsed correctly if "userData" is removed.

Expected results:

Either validate the user input while saving the data or parse the data correctly.

Additional info:

Comment 2 Guohua Ouyang 2023-08-03 11:20:07 UTC
While looking at the script examples here: https://cloudinit.readthedocs.io/en/latest/reference/examples.html
There are no "userData: |" provided in these examples, hence suggest removing it from script UI.

Currently it looks like:
userData: |
  #cloud-config
  user: centos
  password: m62e-b6fg-ve6w
  chpasswd:
    expire: false

Suggestion:
#cloud-config
user: centos
password: m62e-b6fg-ve6w
chpasswd:
  expire: false