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

Upgrade path from 3.11.0 or below to 3.12 or above not smooth due to force replacement by consolidate_disks_on_create #1328

Open
jpbuecken opened this issue Sep 19, 2024 · 1 comment

Comments

@jpbuecken
Copy link

jpbuecken commented Sep 19, 2024

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Terraform v1.9.6
on linux_amd64
+ provider registry.terraform.io/vmware/vcd v3.11.0

Affected Resource(s)

Please list the resources as a list, for example:

  • vcd_vapp_vm
  • vcd_vm

Terraform Configuration Files

terraform {
  required_providers {
    vcd = {
      source  = "vmware/vcd"
      version = "3.11.0"
    }
  }
  required_version = "1.9.6"
}

resource "vcd_vm" "instance" {
  name             = "upgrade-test"
  computer_name    = "upgrade-test"
  vapp_template_id = "urn:vcloud:vapptemplate:d9d38664-be73-4f4c-8da6-42ef78472fb9"
  cpus             = 2
  cpu_cores        = 1
  memory           = 2084

  network {
    type               = "org"
    name               = "xxxxxxx"
    adapter_type       = "vmxnet3"
    ip_allocation_mode = "POOL"
    is_primary         = true
  }
}

Expected Behavior

A provider update from 3.11.0 to 3.12.1 should not forces replacement of vcd_vm or vcd_vapp_vm.

Actual Behavior

After update of the provider AND you try to change a value of the vcd_vm (e.g. increase the number of cpus), this forces a replacement of the VM.

  # vcd_vm.instance must be replaced
-/+ resource "vcd_vm" "instance" {
      + consolidate_disks_on_create    = false # forces replacement

Steps to Reproduce

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

  1. Start with above HCL. Put the code above in a file main.tf
  2. terraform init
  3. terraform apply
  4. Bump provider version in main.tf, e.g. sed -i s/3.11.0/3.12.1/g main.tf
  5. terraform init -upgrade
  6. Check: terraform -v
Terraform v1.9.6
on linux_amd64
+ provider registry.terraform.io/vmware/vcd v3.12.1
  1. Increase cpus. E.g. sed -i s/"cpus = 2"/"cpus = 3"/g main.tf
  2. terraform apply
    You will see the replacement
vcd_vm.instance: Refreshing state... [id=urn:vcloud:vm:b1762165-5d94-4b26-9536-5bb0fa7da624]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # vcd_vm.instance must be replaced
-/+ resource "vcd_vm" "instance" {
      + consolidate_disks_on_create    = false # forces replacement
      + cpu_limit                      = (known after apply)
      ...

Important Factoids

VCD Version 10.6.0.1

@jpbuecken jpbuecken changed the title Upgrade path from 3.11.0 or below to 3.12 or above not smooth due force replacement by consolidate_disks_on_create Upgrade path from 3.11.0 or below to 3.12 or above not smooth due to force replacement by consolidate_disks_on_create Sep 19, 2024
@carmine73
Copy link

carmine73 commented Sep 23, 2024

hi @jpbuecken, as workaround you can use:

resource "vcd_vm" "instance" {
  name             = "upgrade-test"
  computer_name    = "upgrade-test"
  vapp_template_id = "urn:vcloud:vapptemplate:d9d38664-be73-4f4c-8da6-42ef78472fb9"
  cpus             = 2
  cpu_cores        = 1
  memory           = 2084

  network {
    type               = "org"
    name               = "xxxxxxx"
    adapter_type       = "vmxnet3"
    ip_allocation_mode = "POOL"
    is_primary         = true
  }

  lifecycle {
    ignore_changes = [
      # if you don't want VMs to be updated when consolidate_disks_on_create changes (parameter added in 3.12.0)
      consolidate_disks_on_create
    ]
  }
}

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

No branches or pull requests

2 participants