Azure: cloud-init skips formatting the resource disk (ephemeral0) when there is additional data disks' configuration in user-data
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Undecided
|
Unassigned |
Bug Description
Deploying a bionic VM on Azure (Canonical:
#cloud-config
disk_setup:
/dev/
table_type: gpt
layout: True
overwrite: True
fs_setup:
- device: /dev/disk/
partition: 1
filesystem: ext4
mounts:
- [ /dev/disk/
Expected Result:
+ Resource disk (ephemeral0) is formatted as ext4 and mounted to /mnt (which is what happens without attaching the data disk)
Actual Result:
+ Resource disk is partitioned but not formatted, got mounted to /mnt as ntfs
I used this command to create a VM with datadisk and passing in custom data
az vm create -g <resource_group> -n vmname --image Canonical:
I have attached the cloud-init log and the custom data
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/azure/ scsi1/lun0:
disk_setup:
/dev/
table_type: gpt
layout: True
overwrite: True
fs_setup: azure/scsi1/ lun0
- device: /dev/disk/
partition: 1
filesystem: ext4
mounts: azure/scsi1/ lun0, /datadisk1, "ext4", "defaults, nofail, discard" , "0", "0" ]
- [ /dev/disk/
The Azure Datasource will merge these configs together like so:
util.mergemanyd ict([userdata, builtin]) and the combined config looks like
this:
disk_setup: disk/azure/ scsi1/lun0: azure/scsi1/ lun0 azure/scsi1/ lun0 nofail, discard
/dev/
layout: true
overwrite: true
table_type: gpt
ephemeral0:
layout:
- 100
overwrite: true
table_type: gpt
fs_setup:
- device: /dev/disk/
filesystem: ext4
partition: 1
mounts:
- - /dev/disk/
- /datadisk1
- ext4
- defaults,
- '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/azure/ scsi1/lun0:
disk_setup:
ephemeral0:
table_type: gpt
layout: [100]
overwrite: True
/dev/
table_type: gpt
layout: True
overwrite: True
fs_setup: azure/scsi1/ lun0
- device: ephemeral0.1
filesystem: DEFAULT_FS
- device: /dev/disk/
partition: 1
filesystem: ext4
mounts: azure/scsi1/ lun0, /datadisk1, "ext4", "defaults, nofail, discard" , "0", "0" ]
- [ /dev/ephemeral0, /mnt, auto, "defaults,noexec" ]
- [ /dev/disk/