Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot increased attached disk size #2275

Open
3 of 4 tasks
thesefer opened this issue Oct 4, 2024 · 2 comments
Open
3 of 4 tasks

Cannot increased attached disk size #2275

thesefer opened this issue Oct 4, 2024 · 2 comments
Assignees
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Milestone

Comments

@thesefer
Copy link

thesefer commented Oct 4, 2024

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

Terraform v1.4.2

Terraform Provider

v2.8.3

VMware vSphere

8.0.3.00200

Description

It is not possible to extend an attached virtual disk (on a running vm) after v2.8.3 with the Fix provided by #851

Affected Resources or Data Sources

  • resource/vsphere_virtual_machine
  • resource/vsphere_virtual_disk

Terraform Configuration

resource "vsphere_virtual_disk" "PersistentDataDisk" {
  count		              = var.persistent_data_disk == true ? length(var.vms) : 0
  size                  = var.vms[count.index].flavor.disks[1].size
  datacenter            = var.datacenter
  vmdk_path             = "${var.vms[count.index].general.vm_name} - PersistentDisk/${var.vms[count.index].general.host_name}_persistent.vmdk"
  datastore             = var.vms[count.index].general.datastore
  type                  = "thin"
  create_directories    = true
}

resource "vsphere_virtual_machine" "vms" {
  depends_on       = [data.vsphere_virtual_machine.template, vsphere_virtual_disk.PersistentDataDisk]
  count		         = length(var.vms)
  host_system_id   = data.vsphere_host.esxi_hosts[count.index].id
  name             = var.vms[count.index].general.vm_name
  resource_pool_id = data.vsphere_compute_cluster.compute_cluster[count.index].resource_pool_id
  datastore_id     = data.vsphere_datastore.datastores[count.index].id
  annotation	     = var.vms[count.index].custom_attr.annotation
  firmware         = var.firmware
  folder           = var.vms[count.index].location.folder_name
  enable_disk_uuid =  true
  
  custom_attributes = tomap({
    (data.vsphere_custom_attribute.admin_contact.id) = (var.vms[count.index].custom_attr.admin_contact)
    (data.vsphere_custom_attribute.owner_name.id) = (var.vms[count.index].custom_attr.owner_name)
  })

  num_cpus = var.vms[count.index].flavor.cpu
  memory   = var.vms[count.index].flavor.ram
  guest_id = var.vms[count.index].general.guest_id

  dynamic "network_interface" {
    for_each = data.vsphere_network.networks
    content {
      network_id = network_interface.value.id
    }
  }

  dynamic disk {
    for_each = [for i in var.vms[count.index].flavor.disks: { 
      size   = i.size
      number = i.number
      attach = var.persistent_data_disk == true ? true : false
      path   = "${var.vms[count.index].general.vm_name} - PersistentDisk/${var.vms[count.index].general.host_name}_persistent.vmdk"
    }]
    content {
      label = "disk${disk.value.number}"
      unit_number = disk.value.number
      size = (disk.value.attach == true && disk.value.number != 1) || disk.value.attach == false ? disk.value.size : null
      thin_provisioned = (disk.value.attach == true && disk.value.number != 1) || disk.value.attach == false ? true : null
      attach = disk.value.attach == true && disk.value.number == 1 ? disk.value.attach : null
      path = disk.value.attach == true && disk.value.number == 1 ? disk.value.path : null
      datastore_id = disk.value.attach == true && disk.value.number == 1 ? data.vsphere_datastore.datastores[count.index].id : null
    }
  }

  clone {
    template_uuid = data.vsphere_virtual_machine.template[count.index].id

    customize {
      linux_options {
        host_name = var.vms[count.index].general.host_name
        domain = var.vms[count.index].general.domain
      }

      dynamic "network_interface" {
        for_each = [for i in var.vms[count.index].network_interfaces: {
          ipv4_address = i.ipv4_address
          ipv4_netmask = i.ipv4_netmask
        }]
        content {
          ipv4_address = network_interface.value.ipv4_address
          ipv4_netmask = network_interface.value.ipv4_netmask
        }
      }

      dns_server_list = var.global_dns_server_list
      ipv4_gateway = var.global_ipv4_gateway
    }
  }
}

Debug Output

https://gist.github.com/thesefer/4e4aa9028faaeba7cb6feeee617a6b6c

Panic Output

No response

Expected Behavior

I expect the disk to be increased. What I can see in vSphere is a Extend virtual disk operation and I would have expected a Reconfigure virtual machine operation because a disk increase works perfectly fine doing it manually in the webinterface.

vSphere

 Reconfigure virtual machine
 TLP89 - Testinstance - Ansible
 Completed
Reconfiguring Virtual Machine on destination host

Actual Behavior

vSphere

Extend virtual disk
 Unable to access file [S-LP11] TLP89 - Testinstance - Ansible - PersistentDisk/tlp89_persistent.vmdk since it is locked

Terraform

│ Error: Unable to access file [S-LP11] TLP89 - Testinstance - Ansible - PersistentDisk/tlp89_persistent.vmdk since it is locked
│ 
│   with vsphere_virtual_disk.PersistentDataDisk[0],
│   on resources.tf line 48, in resource "vsphere_virtual_disk" "PersistentDataDisk":
│   48: resource "vsphere_virtual_disk" "PersistentDataDisk" {

Steps to Reproduce

  • Create VM with an extra attached disk
  • Increase disk size for attached disk
  • Apply plan

Environment Details

No response

Screenshots

No response

References

#851

@thesefer thesefer added bug Type: Bug needs-triage Status: Issue Needs Triage labels Oct 4, 2024
Copy link

github-actions bot commented Oct 4, 2024

Hello, thesefer! 🖐

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.

@thesefer thesefer changed the title REPLACE WITH A SHORT DESCRIPTION Cannot increased attached disk size Oct 4, 2024
@tenthirtyam
Copy link
Collaborator

Assigning to @spacegospod since this was noted as resolved in v2.8.3 with #2244.

@tenthirtyam tenthirtyam added this to the Backlog milestone Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Type: Bug needs-triage Status: Issue Needs Triage
Projects
None yet
Development

No branches or pull requests

3 participants