Documentation
¶
Overview ¶
Package replacecycle is choudoufu fork port (#2380): remove when upstream #4714 lands. It is unit W3 of #2256, on the fork-port framework (#2376).
The new runtime replaces resource instances, but it has two gaps that made the gap table refuse every replace outside live mode (row "replace-cbd-cycle" of internal/live/newruntime/gaps.json):
- it never checks its execution graph for a cycle (internal/engine/planning/execgraph_resource.go says so in a TODO), so a cycle such as upstream #4714's would surface only during the apply, after some of it had run;
- it never records create_before_destroy in state, so an orphaned object is replaced or destroyed in the wrong order on the next run.
The port closes both: Cycles finds the cycles in a dependency graph, and the planning engine turns any it finds in the execution graph into a plan error (CycleError); the planning and apply engines record create_before_destroy on the objects they write. Its call sites in upstream code are commented with this port's issue.
Removing the port is deleting this package, those call sites and the row's fork_port and switch. It is registered in internal/engine/forkport as Name; switched off, the call sites do nothing and the row refuses a replace outside live mode again.
Index ¶
Constants ¶
const Name = "replacecycle"
Name is the port's name in the internal/engine/forkport registry.
Variables ¶
This section is empty.
Functions ¶
func CycleError ¶
func CycleError(cycles [][]string) tfdiags.Diagnostics
CycleError is the plan error for cycles in the execution graph. Each cycle is the descriptions of the operations in it, which name the resource instances involved.
func Cycles ¶
Cycles returns every cycle among n nodes, each as its node indices in ascending order, ordered by their first index. deps(i) lists the nodes node i depends on. A node that depends on itself is a cycle of one.
It is Tarjan's strongly connected components algorithm, iterative so that a long chain of operations cannot exhaust the stack.
Types ¶
This section is empty.