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

r/virtual_machine: Ensure datastore_id will always have a diff on new disk sub-resources #469

Merged
merged 2 commits into from
Apr 13, 2018

Conversation

vancluever
Copy link
Contributor

@vancluever vancluever commented Apr 12, 2018

This is something that has been an issue for while but is now even more prominent now that datastores don't necessarily need to be specified at all. Owing in part that datastore_id is not populated during the initial TF apply when using the default datastore for disks, changing both the default datastore (or now, possibly, datastore clusters) and a key that forces a new resource at the same time will create a diff mismatch.

A couple of approaches can fix this issue:

  • The first one being marking the datastore_id attribute of the disk sub-resource as Computed, but this method opens the resource up to other bugs when a new disk is taking the place of an old disk in state, and Optional/Computed ultimately results in the old datastore ID setting being grafted into the new sub-resource.
  • The second is to set the datastore_id attribute for new disks that enter the diff to the same value that we give these resources otherwise when the attribute is not present (example: when the disk is not pinned to a datastore).

The latter approach is what was ultimately taken as it fixes the issue without introducing the regression mentioned in the first.

This is something that has been an issue for while but is now even more
prominent now that datastores don't necessarily need to be specified at
all. Owing in part that datastore_id is not populated during the initial
TF apply when using the default datastore for disks, changing both the
default datastore (or now, possibly, datastore clusters) and a key that
forces a new resource at the same time will create a diff mismatch.

Setting datastore_id in the disk sub-resource schema fixes this issue.
@vancluever vancluever added the bug Type: Bug label Apr 12, 2018
@vancluever vancluever requested a review from a team April 12, 2018 14:45
@vancluever vancluever force-pushed the b-vm-disk-subresource-datastore-diff-mismatch branch from 79458b5 to 9fe0b06 Compare April 12, 2018 14:45
After discussing the change to datastore_id in disk sub-resources to
computed, it was determined that there could possibly be scenarios where
this would be damaging to a diff where someone was creating a new disk
at a list location that contained a previous disk's state. This would
result in the old datastore information being grafted into the new disk
due to how Optional/Computed works.

This reverts the schema to the old non-computed form, opting instead to
replace a blank datastore_id with "<computed>" in disk diff when
datastore_id is not supplied. This is then treated the same as an empty
value on virtual disk creation.
@vancluever vancluever changed the title r/virtual_machine: Set datastore_id in disk sub-resource to computed r/virtual_machine: Ensure datastore_id will always have a diff on new disk sub-resources Apr 13, 2018
Copy link
Contributor

@bill-rich bill-rich left a comment

Choose a reason for hiding this comment

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

LGTM

@vancluever vancluever merged commit 664c291 into master Apr 13, 2018
@vancluever
Copy link
Contributor Author

Thanks @bill-rich!

@vancluever vancluever deleted the b-vm-disk-subresource-datastore-diff-mismatch branch April 26, 2018 17:17
@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants