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

make sure all resource apply nodes implement GraphNodeDestroyerCBD #35966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Nov 7, 2024

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

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. 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.
@JohannesMoersch
Copy link

Thanks for the quick resolution of this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants