Loading...
Loading...
### Terraform Version ```shell terraform version 1.5.7 provider[registry.terraform.io/hashicorp/vsphere] 2.3.1 vsphere 7.0.3-01900 open-vm-tools 2:12.2.0-1+deb12u2 govc 0.29.0 ``` ### Terraform Configuration Files ``` disk { label = "linux_system" size = local.system_disk.size thin_provisioned = local.system_disk.thin_provisioned keep_on_remove = local.system_disk.keep_on_remove eagerly_scrub = data.vsphere_virtual_machine.TEMPLATE.disks[0].eagerly_scrub } dynamic "disk" { for_each = var.optional_disks content { size = disk.value.size label = "linux_disk-${disk.key}" unit_number = disk.key + 1 thin_provisioned = disk.value.thin_provisioned keep_on_remove = disk.value.keep_on_remove } } ``` A sample VM was created with : - a 45G system disk, from a VM template (repartitionned using exec, upon first boot to extend existing partitions and create new ones) - a second 5G optional disk (same exec/paritionning treatment on first boot) - a third 10G optional disk (same exec/paritionning treatment on first boot) ### Debug Output The desired result should be : - sda should be the 45G disk - sdb the 5G disk - sdc the 10G disk But sometimes, the detected disk order is any variation of the following ``` # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 5G 0 disk sdb 8:16 0 45G 0 disk ├─sdb1 8:17 0 487M 0 part /boot ├─sdb2 8:18 0 1K 0 part └─sdb5 8:21 0 9.5G 0 part ├─system-swap_1 254:0 0 976M 0 lvm [SWAP] ├─system-root 254:1 0 976M 0 lvm / ├─system-tmp 254:2 0 488M 0 lvm /tmp ├─system-srv 254:3 0 488M 0 lvm /srv ├─system-home 254:4 0 976M 0 lvm /home ├─system-var 254:5 0 976M 0 lvm /var ├─system-var+log 254:6 0 488M 0 lvm /var/log ├─system-var+tmp 254:7 0 488M 0 lvm /var/tmp ├─system-opt 254:8 0 976M 0 lvm /opt └─system-usr 254:9 0 2.8G 0 lvm /usr sdc 8:32 0 10G 0 disk └─sdc1 8:33 0 10G 0 part └─vg_sdc1-lv_varoptfobar 254:10 0 10G 0 lvm /var/opt/fobar ``` ### Expected Behavior The order of disks **should** stay the same Disk the order **must** be the order of declared disks in the resource ### Actual Behavior Power cycling the created VM in a loop gives the following filtered lsblk output : ``` ===== variation NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 10G 0 disk sdb 8:16 0 5G 0 disk sdc 8:32 0 45G 0 disk ===== variation NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 5G 0 disk sdb 8:16 0 45G 0 disk sdc 8:32 0 10G 0 disk ===== The most often seen (and desired) order NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 45G 0 disk sdb 8:16 0 5G 0 disk sdc 8:32 0 10G 0 disk ===== variation NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 45G 0 disk sdb 8:16 0 10G 0 disk sdc 8:32 0 5G 0 disk ===== variation NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 5G 0 disk sdb 8:16 0 10G 0 disk sdc 8:32 0 45G 0 disk ===== variation NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 10G 0 disk sdb 8:16 0 45G 0 disk sdc 8:32 0 5G 0 disk ``` Which shows that any disk order combination can actually happend on **power on** ! Note : once the VM is powered on, the disk order stays the same during reboots. It only may change on VM power cycle (on => off => on) ### Steps to Reproduce 1. create a vsphere vm with multiple disks 2. power off vm, wait, then power on 3. check disk order in guest 4. goto 2 ### Additional Context I have read the following links : - https://github.com/hashicorp/terraform/issues/10225 - https://knowledge.broadcom.com/external/article?legacyId=2011654 - https://www.codyhosterman.com/2020/03/whats-new-in-vsphere-7-0-storage-part-ii-guestinfo-virtualdiskmapping/ So far : - i could not fathom why or how this happens. - i could not find a way to get the order correctly everytime. And i have no clue how to solve this. ### References - #10225 ### Generative AI / LLM assisted development? _No response_
Click on a version to see all relevant bugs
Terraform Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.