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

fix(vm): Make mac_address computed, fix #339 #354

Merged
merged 1 commit into from
Jun 1, 2023

Conversation

otopetrik
Copy link
Contributor

@otopetrik otopetrik commented May 31, 2023

Fields network_interface_names, ipv4_addresses and ipv6_addresses are sometimes be marked computed again, using CustomizeDiff. Changes in VMStarted or VMNetworkDevice attributes invalidate those values. Marking fields computed again avoids stale values.

network_device configuration block without mac_address results in MAC address set to its default value (an empty string). Terraform state expects mac_address to be an empty string, server provides the actual (random) MAC address of the network device. Terraform detects there are changes to be made, but because of DiffSuppressFunc on mac_address they are hidden from the user, but not from d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice)

By making mac_address also computed, the server-generated MAC address is stored locally, avoiding spurious changes that trigger re-computation of network_interface_names, ipv4_addresses and ipv6_addresses.

Contributor's Note

Please mark the following items with an [x] if they apply to your PR.
Leave the [ ] if they are not applicable, or if you have not completed the item.

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated templates in /examples for any new or updated resources / data sources.
  • I have ran make examples to verify that the change works as expected.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #339

Fields `network_interface_names`, `ipv4_addresses` and `ipv6_addresses`
are sometimes be marked `computed` again, using `CustomizeDiff`.
Changes in `VMStarted` or `VMNetworkDevice` attributes invalidate
those values. Marking fields `computed` again avoids stale values.

`network_device` configuration block without `mac_address` results
in MAC address set to its default value (an empty string).
Terraform state expects `mac_address` to be an empty string, server
provides the actual (random) MAC address of the network device.
Terraform detects there are changes to be made, but because of
`DiffSuppressFunc` on `mac_address` they are hidden from the user,
but not from d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice)

By making `mac_address` also `computed`, the server-generated MAC
address is stored locally, avoiding spurious changes that trigger
re-computation of `network_interface_names`, `ipv4_addresses` and
`ipv6_addresses`.
Copy link
Owner

@bpg bpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@otopetrik Awesome, thanks for the quick fix! 🚀

@bpg bpg merged commit e15c4a6 into bpg:main Jun 1, 2023
@ghost ghost mentioned this pull request Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Try to update arguments in every run
2 participants