Comment 2 for bug 1879552

Revision history for this message
Ryan Harper (raharper) wrote :

Hi Anh,

The issue is with built-in config merging with user-data. The Azure
datasource uses this built-in config:

#cloud-config
disk_setup:
  ephemeral0:
     table_type: gpt
     layout: [100]
     overwrite: True

fs_setup:
 - filesystem: DEFAULT_FS
   device: ephemeral0.1

mounts:
 - [ /dev/ephemeral0, /mnt, auto, "defaults,noexec" ]

And in your example the user provides this config

#cloud-config
disk_setup:
  /dev/disk/azure/scsi1/lun0:
    table_type: gpt
    layout: True
    overwrite: True

fs_setup:
  - device: /dev/disk/azure/scsi1/lun0
    partition: 1
    filesystem: ext4

mounts:
 - [ /dev/disk/azure/scsi1/lun0, /datadisk1, "ext4", "defaults,nofail,discard", "0", "0" ]

The Azure Datasource will merge these configs together like so:

util.mergemanydict([userdata, builtin]) and the combined config looks like
this:

disk_setup:
    /dev/disk/azure/scsi1/lun0:
        layout: true
        overwrite: true
        table_type: gpt
    ephemeral0:
        layout:
        - 100
        overwrite: true
        table_type: gpt
fs_setup:
- device: /dev/disk/azure/scsi1/lun0
    filesystem: ext4
    partition: 1
mounts:
- - /dev/disk/azure/scsi1/lun0
    - /datadisk1
    - ext4
    - defaults,nofail,discard
    - '0'
    - '0'

As you can see the fs_setup and mounts are lists, and the default merging
of lists is replacement; the user-data's fs_setup and mounts will override
the built-in config; disk_setup is a dictionary, which by default will merge
missing keys.

This is expected behavior, reserving full user control over the built-in config.
At this time, the only remedy is for users to replicate the built-in config in
their user-data if they would like the ephemeral disk configured the same
way as it would without supplying disk configuration.

#cloud-config
disk_setup:
  ephemeral0:
     table_type: gpt
     layout: [100]
     overwrite: True
  /dev/disk/azure/scsi1/lun0:
    table_type: gpt
    layout: True
    overwrite: True

fs_setup:
  - device: ephemeral0.1
    filesystem: DEFAULT_FS
  - device: /dev/disk/azure/scsi1/lun0
    partition: 1
    filesystem: ext4

mounts:
 - [ /dev/ephemeral0, /mnt, auto, "defaults,noexec" ]
 - [ /dev/disk/azure/scsi1/lun0, /datadisk1, "ext4", "defaults,nofail,discard", "0", "0" ]