Public bug reported:

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.

** Affects: cloud-init
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/2009236

Title:
  Cloud-init inconsistently uses config

Status in cloud-init:
  New

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.

To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/2009236/+subscriptions


-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to