r/virtual_machine: Ensure datastore_id will always have a diff on new disk sub-resources #469
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
datastore_id
attribute of thedisk
sub-resource asComputed
, 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 latter approach is what was ultimately taken as it fixes the issue without introducing the regression mentioned in the first.