Skip to content

always check the CreateBeforeDestroy value from state#26263

Merged
jbardin merged 3 commits intomasterfrom
jbardin/cbd-from-state
Sep 16, 2020
Merged

always check the CreateBeforeDestroy value from state#26263
jbardin merged 3 commits intomasterfrom
jbardin/cbd-from-state

Conversation

@jbardin
Copy link
Copy Markdown
Member

@jbardin jbardin commented Sep 16, 2020

When destroying an instance which was forced to be CreateBeforeDestroy from downstream consumers, we were inadvertently preferring the config value over the state value for CreateBeforeDestroy. The CreateBeforeDestroyOverride was not useful in this case, because a destroy node does not have the same descendants as the plan node, and we cannot check for a forced CreateBeforeDestroy in the same manner, so we need to trust the value from state.

The last commit is extra cleanup of some unnecessary interfaces, and is not going to be part of the backport candidate.

This fixes the cycle in #26226, and converts it into a duplicate of #25631.

When there is only a destroy node, there is no descendent to check for
"forced CBD", so we can only rely on the state to verify.
Correct the initial test state, and expand the test to cause a cycle
without the previous fix.
@jbardin jbardin requested a review from a team September 16, 2020 14:57
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 16, 2020

Codecov Report

Merging #26263 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
terraform/node_resource_apply_instance.go 81.30% <ø> (+0.98%) ⬆️
terraform/transform_destroy_cbd.go 82.97% <ø> (ø)
terraform/transform_destroy_edge.go 87.77% <ø> (-0.40%) ⬇️
terraform/node_resource_destroy.go 78.16% <100.00%> (+2.60%) ⬆️
backend/remote/backend_common.go 54.57% <0.00%> (-0.68%) ⬇️
dag/marshal.go 54.44% <0.00%> (+1.11%) ⬆️
terraform/node_resource_plan.go 93.44% <0.00%> (+1.63%) ⬆️
terraform/transform_reference.go 90.83% <0.00%> (+2.39%) ⬆️

n.destroyNode = d
}

// CreateBeforeDestroy checks this nodes config status and the status af any
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is out of date now? It's no longer checking the companion destroy node?

Copy link
Copy Markdown
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me (admittedly based more off your tests and explanation)! I left one tiny question about a comment; its not a blocker.

Remove the check for CreateBeforeDestroyOverride which can't happen in a
destroy node.

Remove the unnecessary GraphNodeAttachDestroyer interface, since we
don't use it now that plans can record the create+destroy order.
@jbardin jbardin force-pushed the jbardin/cbd-from-state branch from a250b05 to a6dffa8 Compare September 16, 2020 15:14
@jbardin jbardin merged commit 5c69cf0 into master Sep 16, 2020
@jbardin jbardin deleted the jbardin/cbd-from-state branch September 16, 2020 15:32
jbardin added a commit that referenced this pull request Sep 16, 2020
@ghost
Copy link
Copy Markdown

ghost commented Oct 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants