nutanix / terraform-provider-nutanix

Terraform Nutanix Provider
https://www.terraform.io/docs/providers/nutanix/
Mozilla Public License 2.0
99 stars 112 forks source link

Changing nutanix_virtual_machine description needlessly restarts VM #574

Open jantari opened 1 year ago

jantari commented 1 year ago

Nutanix Cluster Information

Please provide the version of:

Terraform Version

Terraform v1.4.2 on linux_amd64

Affected Resource(s)

Terraform Configuration Files

resource "nutanix_virtual_machine" "server" {
  count                = 1
  name                 = "prod-db-fundb${format("%02d", count.index)}"
  description          = join(" ", [
                           "Database Server of fun.",
                           "Repository: https://git.domain.tld/platforms/fun"
                         ])
  num_sockets          = 4
  num_vcpus_per_socket = 1
  memory_size_mib      = 17312

  hardware_clock_timezone = "Europe/Berlin"

  cluster_uuid = local.cluster_b

  nic_list {
    subnet_uuid = data.nutanix_subnet.subnet_prod_b.id
  }

  disk_list {
    data_source_reference = {
      kind = "image"
      uuid = "<SOME_UUID>"
    }
    device_properties {
      disk_address = {
        device_index = 0
        adapter_type = "SCSI"
      }
      device_type = "DISK"
    }
  }

  disk_list {
    device_properties {
      disk_address = {
        device_index = 1
        adapter_type = "SCSI"
      }
      device_type = "DISK"
    }
    disk_size_mib = 256000
  }

  disk_list {
    device_properties {
      disk_address = {
        device_index = 2
        adapter_type = "IDE"
      }
      device_type = "CDROM"
    }
  }

  nutanix_guest_tools = {
    state           = "ENABLED"
    iso_mount_state = "MOUNTED"
  }

  lifecycle {
    ignore_changes = [
      nutanix_guest_tools,
      disk_list[0].data_source_reference,
    ]
  }
}

Debug Output

I will do this if it's requested and really needed, looking through the entire debug output many times over to ensure it is sanitized is a lot of work.

Panic Output

no panic

Expected Behavior

The VMs description should have been updated in-place without restarting / power-cycling the VM.

Actual Behavior

The VM was needlessly restarted.

Steps to Reproduce

  1. Provision a nutanix_virtual_machine with terraform
  2. Change the description
  3. Perform a plan - it will show that the description will be updated in-place
  4. Apply the plan - the VM will be restarted just for a description change

Important Factors

We are using AHV hypervisor and Prism Central on official Nutanix hardware.

References

Terraform plan output:

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
Terraform will perform the following actions:
  # nutanix_virtual_machine.server[0] will be updated in-place
  ~ resource "nutanix_virtual_machine" "server" {
      ~ description                                      = "Database Server of fun" -> "Database Server of fun. Repository: https://git.domain.tld/platforms/fun"
        id                                               = "<VM_UUID>"
        name                                             = "prod-db-fundb00"
        # (35 unchanged attributes hidden)
      - timeouts {}
        # (4 unchanged blocks hidden)
    }
Plan: 0 to add, 1 to change, 0 to destroy.

Restart showing in Prism Central Tasks:

image

Restart evidenced by ping drop:

image

abhimutant commented 1 year ago

Hi @jantari , we have tried the same with pc 2022.9 . We weren't able to see the restarting of VM by updating the description. We have used your resource information to verify the behaviour . Can you give it a try with pc 2022.9 ? Do let us know if you are still facing the same.

abhimutant commented 1 year ago

Hi @jantari ,can you confirm if you are still able to see this issue ?