Cloud-init inconsistently uses config

Bug #2009236 reported by Brett Holman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Expired
Medium
Unassigned

Bug Description

On boot, cloud-init is able to pass cloud-config via userdata_raw, a useful feature when testing behavior on a datasource that doesn't have its own way of retrieving userdata.

system_info:
   datasource:
     None:
       userdata_raw: "#cloud-config\ngrub_dpkg:\n enabled: true"

This works during boot as one might expect:

2023-03-03 21:15:59,255 - modules.py[DEBUG]: Running module grub-dpkg (<module 'cloudinit.config.cc_grub_dpkg' from '/
usr/lib/python3/dist-packages/cloudinit/config/cc_grub_dpkg.py'>) with frequency once-per-instance
2023-03-03 21:15:59,256 - handlers.py[DEBUG]: start: modules-config/config-grub-dpkg: running config-grub-dpkg with frequency once-per-instance

However, cloud-init's single subcommand clearly uses a different configuration, since the following fails to run the same module with the same config:

```
cloud-init --debug --force single --frequency always --name cc_grub_dpkg
```

Furthermore, this userdata_raw isn't included in /run/cloud-init/instance-data-sensitive.json, nor in cloud-init query -a.

Alarmingly, an invalid config provided via userdata_raw is not warned of by cloud-init schema --system:

```
system_info:
   # This will affect which distro class gets used
   datasource:
     NoCloud:
       userdata_raw: |
         #cloud-config
         grub_dpkg:
           enabled: true
           invalid-key: true
```

output:
```
# cloud-init schema --system
Found cloud-config data types: user-data, vendor-data

1. user-data at /var/lib/cloud/instances/cloudinit-0302-160255pw859u9h/cloud-config.txt:
  Valid cloud-config: user-data

2. vendor-data at /var/lib/cloud/instances/cloudinit-0302-160255pw859u9h/vendor-cloud-config.txt:
  Valid cloud-config: vendor-data
 ```

These details reveal inconsistency in cloud-init config handling, and all contribute to a confusing user experience when using userdata_raw.

There may be other inconsistencies too - configs passed directly on the kernel commandline (cc: <config> end_cc), and configs sourced from a url via the kernel commandline (cloud-config-url=) are both used during boot - but I haven't looked to see whether they behave correctly with (schema|single|query) subcommands or show up in /run/cloud-init/instance-data-sensitive.json, but after this finding we probably aught to audit for other issues like this.

James Falcon (falcojr)
Changed in cloud-init:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
James Falcon (falcojr) wrote :
Changed in cloud-init:
status: Triaged → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.