mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
check walkDestroy to help DestroyEdgeTransformer
In a heavily-connected graph with lots of inter-dependent providers, the cycle checks for destroy edges across providers can seriously impact performance. Since the specific cases we need to avoid will involve create/update nodes, skip the extra checks during a full destroy operation. Once we find a way to better track these dependencies, the transformer will not need to do the cycle checks in the first place.
This commit is contained in:
parent
069cc3eec9
commit
b6a67f622f
@ -144,7 +144,8 @@ func (b *ApplyGraphBuilder) Steps() []GraphTransformer {
|
|||||||
|
|
||||||
// Destruction ordering
|
// Destruction ordering
|
||||||
&DestroyEdgeTransformer{
|
&DestroyEdgeTransformer{
|
||||||
Changes: b.Changes,
|
Changes: b.Changes,
|
||||||
|
Operation: b.Operation,
|
||||||
},
|
},
|
||||||
&CBDEdgeTransformer{
|
&CBDEdgeTransformer{
|
||||||
Config: b.Config,
|
Config: b.Config,
|
||||||
|
@ -46,6 +46,11 @@ type DestroyEdgeTransformer struct {
|
|||||||
// DiffTransformer which was intended to be the only transformer operating
|
// DiffTransformer which was intended to be the only transformer operating
|
||||||
// from the change set.
|
// from the change set.
|
||||||
Changes *plans.Changes
|
Changes *plans.Changes
|
||||||
|
|
||||||
|
// FIXME: Operation will not be needed here one we can better track
|
||||||
|
// inter-provider dependencies and remove the cycle checks in
|
||||||
|
// tryInterProviderDestroyEdge.
|
||||||
|
Operation walkOperation
|
||||||
}
|
}
|
||||||
|
|
||||||
// tryInterProviderDestroyEdge checks if we're inserting a destroy edge
|
// tryInterProviderDestroyEdge checks if we're inserting a destroy edge
|
||||||
@ -81,6 +86,12 @@ func (t *DestroyEdgeTransformer) tryInterProviderDestroyEdge(g *Graph, from, to
|
|||||||
e := dag.BasicEdge(from, to)
|
e := dag.BasicEdge(from, to)
|
||||||
g.Connect(e)
|
g.Connect(e)
|
||||||
|
|
||||||
|
// If this is a complete destroy operation, then there are no create/update
|
||||||
|
// nodes to worry about and we can accept the edge without deeper inspection.
|
||||||
|
if t.Operation == walkDestroy {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// getComparableProvider inspects the node to try and get the most precise
|
// getComparableProvider inspects the node to try and get the most precise
|
||||||
// description of the provider being used to help determine if 2 nodes are
|
// description of the provider being used to help determine if 2 nodes are
|
||||||
// from the same provider instance.
|
// from the same provider instance.
|
||||||
|
Loading…
Reference in New Issue
Block a user