Skip to content

r/virtual_machine: apply SDRS recommendation to all disks on datastore_cluster #2448

@munawar0230

Description

@munawar0230

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

1.9.3 (TFE - v202410-1)

Terraform Provider

hashicorp/vshpere v2.8.1

VMware vSphere

8.0.3.00400 (Build 24322831)

Description

SDRS Configuration:

Datastore type: VMFS 5 and VMSF 6

In this setup, we have a storage distribution cluster created. Each data store cluster has up to 64 data stores present within it. Provisioning is expected to target the data store cluster, which then relies on the intelligent placement feature within VMware SDRS to select the appropriate data store.

Terraform Configuration:

Terraform is configured 1st to identify the ID of the provided data store cluster.

data "vsphere_datastore_cluster" "datastore_cluster" (
   name = var. datastore_clustername
   datacenter_id = data.vsphere_datacenter.datacenter.id
}

Later, we define the required disk within the VM provisioning to request all of the defined disks.

dynamic "disk" {
  for_each = var.disks
  content {
    label = disk.value.label
    size = disk.value.size
    thin_provisioned = disk.value.thin_provisioned
    disk_mode = disk. value.disk_mode
    unit_number = index(var.disks, disk.value)
    length(data.vsphere_virtual_machine.template.disks)
  }
}

We are using this as the resource for virtual disk disk or only support data store and does not support datastore cluster. If it had supported datastore cluster, we might have created the virtual disk and attached to the VM and tried.

resource "vsphere_virtual_disk" "virtual_disk" {
  size               = 40
  type               = "thin"
  vmdk_path          = "/foo/foo.vmdk"
  create_directories = true
  datacenter         = data.vsphere_datacenter.datacenter.name
  datastore          = data.vsphere_datastore.datastore.name
}

Regardless, the expectation is the different disk requested to be placed intelligently by VMware to the available datastores withing the cluster, but we see that even though vm affinity is set to false for the ds cluster all the disks are trying to be created in the same datastore and not able to find space.

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

resource "vsphere_virtual_machine" "vm" {
  name = "my-vm"
  datacenter_id = data.vsphere_datacenter.default.id
  resource_pool_id = data.vsphere_compute_cluster.default.resource_pool_id
  datastore_cluster_id = data.vsphere_datastore_cluster.mycluster.id

  # ... other virtual machine settings ...
 
  disk {
    unit_number = 0 # Typically the boot disk
    size = 2000
  }
 
  disk {
    unit_number = 1 # First additional disk
    size = 2000
  }
 
  disk {
    unit_number = 2 # Second additional disk
    size = 2000
  }
}

Debug Output

https://gist.github.com/munawar0230/d9edd77c50f124ba19485ae43d614c37

Panic Output

No response

Expected Behavior

Using the following configuration, the expected behavior is to receive the SDRS recommendation and place the disk on the space-available datastore.

Actual Behavior

Using the following configuration, all the disks are trying to be placed on the first datastore returned from vSphere and failing..

Steps to Reproduce

  1. Setup a VM ware datastore cluster with multiple datastore with 4TB each.
  2. run the terraform sample code

Environment Details

No response

Screenshots

SendSafely_download_ZMAS-YFVV.zip

References

Broadcom Case#36293260
Hashicorp ticket # #181494

Metadata

Metadata

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions