hashicorp / terraform-provider-vsphere

Terraform Provider for VMware vSphere
https://registry.terraform.io/providers/hashicorp/vsphere/
Mozilla Public License 2.0
619 stars 453 forks source link

Storage Migration between Datastores and Datastore Clusters doesn't work #1832

Open rogermartensson opened 1 year ago

rogermartensson commented 1 year ago

Community Guidelines

Terraform

1.3.6

Terraform Provider

2.2.0

VMware vSphere

vSphere 6.7

Description

Migration between regular Datastores and Datastore Clusters doesn't seem to work. Changes are made but no migration is started when running terraform apply.

Affected Resources or Data Sources

resource vsphere_virtual_machine

Terraform Configuration

This is an not a fully working example of what I use to create a VM. Because environments may differ. The important bit is the settings for "datastore_id" and "datastore_cluster_id".

 resource "vsphere_virtual_machine" "vm" {
  name             = "testserver"
  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_cluster_id     = data.vsphere_datastore_cluster.datastore_cluster.id
  # datastore_id = data.vsphere_datastore.vmdatastore.id
  num_cpus         = 1
  memory           = 1024
  guest_id         = 'ubuntu64guest'
  network_interface {
    network_id   = data.vsphere_network.network.id
    adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
  }
  disk {
    label            = "disk0"
    thin_provisioned = data.vsphere_virtual_machine.template.disks.0.thin_provisioned
    eagerly_scrub    = data.vsphere_virtual_machine.template.disks.0.eagerly_scrub
  }
  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
  }
 vapp {
    properties ={
      user-data = data.cloudinit_config.userdata.rendered
    }
  }

Debug Output

Nothing out made on vSphere. Terraform outputs that changes are made to datastore_id and datastore_cluster_id.

Panic Output

No response

Expected Behavior

Expected the VM to migrate to and from Datastores and Datastore Clusters.

Actual Behavior

Nothing happens in vSphere environment.

Steps to Reproduce

1) Create VM on Datastore Cluster 2) Replace datastore_cluster_id with a datastore_id 3) terraform apply

Environment Details

No response

Screenshots

No response

References

No response

github-actions[bot] commented 1 year ago

Hello, rogermartensson! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

tenthirtyam commented 1 year ago

The suggested steps to reproduce are opposite of the issue context.

Description Context: datastore_id to datastore_cluster_id

Reproduction Steps:

_“Replace datastore_cluster_id with a datastore_id._

Can you confirm if both cases produce the same negative result?

rogermartensson commented 1 year ago

Storage migration from Datastore (datastore_id) to Datastore Cluster (datastore_cluster_id) works.

Storage migration from Datastore Cluster to Datastore does not work.

      - datastore_cluster_id                    = "group-p1732" -> null
      ~ datastore_id                            = "datastore-1731" -> "datastore-1185"

I see a "Relocate" message appearing in vCenter but no disks are relocated.

Now that you asked me I looked in the Advanced view (per disk) in the migration wizard on the vCenter-server. Only the configuration file was migrated. Not the disks.