core: update destroy graph pruning to handle ephemeral resources #35890
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.
Ephemeral resources were the straw that broke the
pruneUnusedNodesTransformer
's back. This transformer has always been in a tough spot, trying to maintain legacy behaviors around destroy, while keeping destroy operations from failing entirely from configuration evaluation errors. As we've tidied up graph creation over many prior versions, there were just a few node types which were incorrectly classified that were preventing us from inverting thepruneUnusedNodesTransformer
logic to the more reasonable task of finding what to keep, rather than finding what to exclude.With the missing destroy node types sorted out, the
pruneUnusedNodesTransformer
no longer needs to keep up with the whack-a-mole game of detecting nodes which might need to be skipped. When executing a destroy operation, we can never be certain that the state will contain all the data required to evaluate the entire configuration. This could be because of a previously failed apply operation, or external changes made out of band. This means that once we process the configuration to get the providers hooked up, we need to somehow remove any nodes that correspond to configuration values that may not be available to evaluate.In a destroy operation we primarily need three categories of nodes to complete the plan and apply:
Other than that minimal set of required nodes, the rest are no longer necessary and should be skipped to avoid any errors that could block the apply operation.