don't refresh deposed instances during the destroy plan#29720
Conversation
Have the MockProvider ensure that Configure is always called before any methods that may require a configured provider. Ensure the MockProvider *Called fields are zeroed out when re-using the provider instance.
The destroy plan should not require a configured provider (the complete configuration is not evaluated, so they cannot be configured). Deposed instances were being refreshed during the destroy plan, because this instance type is only ever destroyed and shares the same implementation between plan and walkPlanDestroy. Skip refreshing during walkPlanDestroy.
Resetting the *Called fields and enforcing configuration broke a few tests.
bflad
left a comment
There was a problem hiding this comment.
I can confirm terraform destroy on 1.1.0-alpha20211006 does not work in this scenario, while this branch does. 🎉
|
This will require a manual backport of the |
|
go1.17.2 made a change that updates the |
v1.0 backport of #29720: skip refreshing deposed during destroy plan
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
The
NodePlanDeposedResourceInstanceObjectis used in both a regular plan, and in a destroy plan, because the only action needed for a deposed instance is to destroy it so the functionality is mostly identical.A major difference between these two plans however is that a regular plan can refresh instances, while a destroy plan is done without any interaction from the provider. Since
NodePlanDeposedResourceInstanceObjectis also used for a normal plan, it contains the code to refresh the instance, which needs to be skipped during a destroy plan.The other instance types don't have this problem because they have different plan node types for plan destroy. We could create a new type for
NodePlanDestroyDeposedResourceInstanceObject, but the only difference would be missingrefreshcall, so for now we can just add another conditional based on the walk operation.In order to try and prevent similar issues, the MockProvider is updated to check that the provider is configured for all calls that may require it, and the
*Calledfields are zeroed out when the provider is reused.Fixes #29712