replacecycle

package
v0.34.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MPL-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Cycles(n int, deps func(int) []int) [][]int

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.

func Enabled

func Enabled() bool

Enabled reports whether the port is on.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL