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

Merged
merged 1 commit into from
Nov 8, 2024

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!

@jbardin jbardin added the 1.10-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Nov 8, 2024
@jbardin jbardin merged commit 7631828 into main Nov 8, 2024
6 checks passed
@jbardin jbardin deleted the jbardin/missing-apply-cbd branch November 8, 2024 13:39
Copy link
Contributor

github-actions bot commented Nov 8, 2024

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

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.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.10-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
3 participants