Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove some destroy cycles #22976
This PR removes extra connections from the graph which are unneeded, however only cause problems in certain destroy scenarios. This solves a number of common cycles issues, while simplifying the graph itself. It does not solve all cycles, as destroy nodes still need their references evaluated in order for destroy-provisioners to function.
Destroy nodes do not need to be connected to the resource (prepare
Under normal circumstances this makes no difference, as create and
If a resource is only destroying instances, there is no reason to
These failures were previously blocked by there being a cycle when the
This depends on jbardin/cbd-modules, and can be merged into that first, or re-targeted to later to master.
Destroy-time references are not correctly or fully inverted when crossing module boundaries, causing cycle during apply.
Destroy nodes do not need to be connected to the resource (prepare state) node when adding them to the graph. Destroy nodes already have a complete state in the graph (which is being destroyed), any references will be added in the ReferenceTransformer, and the proper connection to the create node will be added in the DestroyEdgeTransformer. Under normal circumstances this makes no difference, as create and destroy nodes always have an dependency, so having the prepare state handled before both only linearizes the operation slightly in the normal destroy-then-create scenario. However if there is a dependency on a resource being replaced in another module, there will be a dependency between the destroy nodes in each module (to complete the destroy ordering), while the resource node will depend on the variable->output->resource chain. If both the destroy and create nodes depend on the resource node, there will be a cycle.
If a resource is only destroying instances, there is no reason to prepare the state and we can remove the Resource (prepare state) nodes. They normally have pose no issue, but if the instances are being destroyed along with their dependencies, the resource node may fail to evaluate due to the missing dependencies (since destroy happens in the reverse order). These failures were previously blocked by there being a cycle when the destroy nodes were directly attached to the resource nodes.
I'm going to lock this issue because it has been closed for 30 days
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.