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

Provider doesn't customize disk template at request time but after VM creation #1000

Closed
drgogeta86 opened this issue Feb 17, 2023 · 3 comments · Fixed by #1206
Closed

Provider doesn't customize disk template at request time but after VM creation #1000

drgogeta86 opened this issue Feb 17, 2023 · 3 comments · Fixed by #1206
Assignees

Comments

@drgogeta86
Copy link

drgogeta86 commented Feb 17, 2023

Terraform Version

Terraform v1.3.9

Affected Resource(s)

Please list the resources as a list, for example:

  • vcd_vapp_vm

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "vcd_vapp" "vminfra" {
  name = var.vcd_vm_vapp_name

}


resource "vcd_vapp_org_network" "vminfra" {
    org = var.vcd_org # Optional
    vdc = var.vdc_name # Optional
    vapp_name = var.vcd_vm_vapp_name
    org_network_name = var.vcd_org_network_name

  depends_on = [
    vcd_vapp.vminfra
  ]

}

data "vcd_catalog" "boxes" {
  org  = var.vcd_org
  name = "MYCatalog"
}

data "vcd_catalog_vapp_template" "lampstack" {
  org        = var.vcd_org
  catalog_id = data.vcd_catalog.boxes.id
  name       = "my-template"
}

resource "vcd_vapp_vm" "vminfra" {
  vapp_name     = var.vcd_vm_vapp_name
  name          = var.vcd_vm_name
  vapp_template_id = data.vcd_catalog_vapp_template.lampstack.id
  memory        = var.vcd_vm_ram
  cpus          = var.vcd_vm_vcpu
  cpu_cores     = var.vcd_vm_socket
  power_on = false


  override_template_disk {
    bus_type        = "paravirtual"
    size_in_mb      = "52384"
    bus_number      = 0
    unit_number     = 0
    iops            = 0
    storage_profile = "ALLOCATION-FC VM Storage Profile"
  }


  depends_on = [
    vcd_vapp_org_network.vminfra
  ]


}

Debug Output

https://gist.github.com/drgogeta86/612c6eb808c6ad3945ef00ca29042963

Expected Behavior

The module vdc_vapp_vm must implement override_template_disk.size_in_mb while calling instantiateVAppTemplate instead to reconfigure the machine after creation ( mandatory on fast provisioned Storage Policies )

Actual Behavior

Tries to reconfigure the virtual machine and fails

│ Error: error creating VM from template: error managing internal disks : error updating VM disks: error updating VM disks: API Error: 400: [ 7930ecce-417c-4ddf-bc46-e9adfe93348e ] The hard drives of the virtual machine "my-testhost" cannot be modified while the virtual machine has snapshots.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply
@adezxc
Copy link

adezxc commented Mar 21, 2023

Hello @drgogeta86, thanks for the contribution.

Right now, we don't plan to use the instantiateVAppTemplate for creating vApps because of multiple reasons. As a workaround, could you perhaps create a new vApp template in the UI with the custom disk size and then create VMs using that? That way you shouldn't need to use override_template_disk at all.

@Didainius
Copy link
Collaborator

Hello @drgogeta86 , we have chosen a slightly different path, but giving the same result (a full VM clone, instead of linked one) and it is implemented in #1206.
The reason why we didn't choose to use instantiateVAppTemplate is that it creates a vApp and a VM at the same time. This does not suit Terraform model we have.
We have done investigation to find out if the reconfigurevApp endpoint can also change disk, but unfortunately it isn't supported.

@Didainius
Copy link
Collaborator

@drgogeta86 , we have introduced a solution for this (as describe in #1206 which is now in main and will be part of 3.12 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants