make sure all resource apply nodes implement GraphNodeDestroyerCBD
#35966
+109
−27
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.
If an instance was forced to be CreateBeforeDestroy due to a dependent, and that dependent had no changes to apply, the dependent would not be in the graph to force the CBD status on the change, and the result would be lost from the state.
This rarely made any difference, because the status would be restored during the next plan, which is why it was not noticed until now. However if the resource was immediately removed from the configuration, the incorrect state would be the only source of the destroy order, which could result in a cycle during the next apply.
While it would be better to use the destroy order calculated during plan, when there is a newly created object its plan state is not stored because the instance has a null state value. This means we still need to recompute the CBD status again during apply until a new way to transfer the information from plan to apply is developed.
While instances without changes are not present in the apply graph, their resource expansion nodes do happen to be there and hold the configuration (and while they were previously an implementation quirk of the expansion system, they now play an important role in the ephemeral resource evaluation). Those resource expansion nodes didn't implement the
GraphNodeDestroyerCBD
interface though, which was why the CBD status was not picked up during apply.The fix is relatively easy, move the
GraphNodeDestroyerCBD
implementation down to the abstract resource node, to make sure all resources nodes implement the behavior. The nodes which need a different implementation already have it, and thus will override the embedded methods.Fixes #35959