terraform-provider-vsphere icon indicating copy to clipboard operation
terraform-provider-vsphere copied to clipboard

vsphere_virtual_machine will be updated in-place

Open ghost opened this issue 1 year ago • 16 comments

Community Guidelines

  • [X] I have read and agree to the HashiCorp Community Guidelines .
  • [X] Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • [X] Do not leave "+1" or other comments that do not add relevant information or questions.
  • [X] If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Terraform

v1.4.6

Terraform Provider

v2.3.1 and v2.4.0

VMware vSphere

v8.0.1

Description

After a virtual machine is created using the provider, after running an apply again Terraform wants to update the virtual-machine in-place as the fields ept_rvi_mode and hv_mode are constantly being changed even without touching those fields. It looks like that the provider is using one of automatic, on or off, where VSphere unsets the field to an empty string "".

As a work-around I can use the following block

lifecycle {
    ignore_changes = [
      ept_rvi_mode,
      hv_mode
    ]
  }

Affected Resources or Data Sources

resource/vsphere_virtual_machine

Terraform Configuration

Debug Output

Panic Output

No response

Expected Behavior

No changes

Actual Behavior

# module.workers["worker-06"].vsphere_virtual_machine.main will be updated in-place
  ~ resource "vsphere_virtual_machine" "main" {
      + ept_rvi_mode                            = "automatic"
      + hv_mode                                 = "hvAuto"
         id                                     = "..."
        name                                    = "vm-01"
        tags                                    = []
        # (69 unchanged attributes hidden)

Steps to Reproduce

Run a terraform apply immediatly followed by a new run of terraform apply

Environment Details

No response

Screenshots

No response

References

No response

ghost avatar May 11 '23 12:05 ghost

Hello, ebruurs! 🖐

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.

github-actions[bot] avatar May 11 '23 12:05 github-actions[bot]

Seeing the same behaviour; ESXi & vCenter 8.0.1, Terraform v1.4.6, vSphere provider v2.4.0.

uprightvinyl avatar May 12 '23 05:05 uprightvinyl

Both default to automatic. One option may be to set these to computed like was done for annotation recently but they would still use the validation. cc @appilon

https://github.com/hashicorp/terraform-provider-vsphere/blob/29a4c6ce2e7723e3bbeb58c5f12d5292b82c1b6c/vsphere/virtual_machine_config_structure.go#L26-L36

https://github.com/hashicorp/terraform-provider-vsphere/blob/29a4c6ce2e7723e3bbeb58c5f12d5292b82c1b6c/vsphere/virtual_machine_config_structure.go#L127-L140

tenthirtyam avatar May 12 '23 13:05 tenthirtyam

Same issue encountered today with latest provider and latest Vmware vCenter 8.0.1.

captainfalcon23 avatar Aug 01 '23 07:08 captainfalcon23

same issue for us with latest provider and vcenter 8

gmintoco avatar Aug 04 '23 17:08 gmintoco

Same here. We have reproduced this on vCenter 8 and esxi 8. If vCenter 8 with esxi 7 works fine.

kbpsec avatar Aug 25 '23 08:08 kbpsec

Any update on this? I am running into same issue with latest provider.

pramodsharma62 avatar Aug 30 '23 23:08 pramodsharma62

Can confirm also hit the issues on vCenter 8U1a and ESXi 8U1a (VCF5)

DSI-BenThomas avatar Sep 06 '23 19:09 DSI-BenThomas

Can confirm this on hosts using ESXi and vCenter 8.0.2, ESXi 6.7 do not have the unintended side effects.

LargoUsagi avatar Nov 02 '23 20:11 LargoUsagi

Still an issue, even after manually defining the fields.

Latest version of the provider. vCenter 8.0.1 (build 21815093) and ESXi 8.0.2 (build 22380479).

Hello-User avatar Dec 29 '23 23:12 Hello-User

same issue for us with latest provider and vcenter 8

smhick avatar Jan 02 '24 15:01 smhick

We face the same problem: Terraform v1.6.0 Terraform Provider v2.5.1 VMware vSphere v8.0.1

micropbl4 avatar Jan 05 '24 11:01 micropbl4

im hitting this too

nc-td avatar Jan 05 '24 19:01 nc-td

We hit same issue with: Terraform v1.3.7 registry.terraform.io/hashicorp/vsphere v2.6.0 esxi: 8.0.2 22380479 vcenter: 8.0.2.00000

Aly-ona avatar Jan 11 '24 10:01 Aly-ona

same issue

smooti avatar Jan 18 '24 15:01 smooti

Same issue Workaround for now to add

lifecycle { ignore_changes = [hv_mode, ept_rvi_mode] }

to the resource

Flumeded avatar Jan 30 '24 20:01 Flumeded

@stoyan-hristov - can you look into this one as well?

tenthirtyam avatar Apr 17 '24 19:04 tenthirtyam

@tenthirtyam We can't make them computed and keep the default value at the same time. Terraform does not permit this combination.

Just removing the defaults solves the problem. We can stll apply them in the create method if necessary

spacegospod avatar Apr 19 '24 10:04 spacegospod

Reverted in 2.8.1. Reopening.

tenthirtyam avatar May 08 '24 21:05 tenthirtyam

Going to reintroduce the fix as a breaking change in the next major release

spacegospod avatar May 15 '24 10:05 spacegospod

Vsphere provider 2.8.1 Vsphere 8.0.2.00300

I'm still having the issue, VM are rebooting. I've implemented the workaround with the lifecycle from above.

Just to make sure, is 2.8.1 supposed to fix the issue, or am I missing something?

DamienDaco avatar May 28 '24 10:05 DamienDaco

Vsphere provider 2.8.1 Vsphere 8.0.2.00300

I'm still having the issue, VM are rebooting. I've implemented the workaround with the lifecycle from above.

Just to make sure, is 2.8.1 supposed to fix the issue, or am I missing something?

Hey @DamienDaco The fix was released with 2.8.0 but it caused updates to running VMs created with older versions so we decided to issue a patch and revert this change in 2.8.1

We consider this fix to be a breaking change since it can interrupt running workloads because the update to the configuration triggers a power cycle on the VMs.

We try to allow breaking changes only on major releases, that is why the fix for this issue will likely land with v3.0.0

spacegospod avatar May 30 '24 08:05 spacegospod

Research Note: Was reported in https://github.com/hashicorp/terraform-provider-vsphere/issues/2202#issuecomment-2124459375 that this issue is not observed in vSphere 7. Verification reequired.

tenthirtyam avatar Jun 12 '24 01:06 tenthirtyam

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

github-actions[bot] avatar Jul 27 '24 02:07 github-actions[bot]