Commit Graph

17 Commits

Author SHA1 Message Date
James Bardin 0b31ffa587 use a single log writer
Use a single log writer instance for all std library logging.

Setup the std log writer in the logging package, and remove boilerplate
from test packages.
2020-10-19 14:29:54 -04:00
James Bardin 6ca477f042 move helper/logging to internal
remove a dead code file too
2020-10-19 14:27:53 -04:00
James Bardin 37a7d904aa dag benchmark 2020-02-19 14:53:19 -05:00
James Bardin 6096371068 remove all unneeded list-based iteration
Make the default walks always use the sets directly, which avoids
repeated copying of every set into a new slice.
2020-02-19 14:53:19 -05:00
Martin Atkins 2c70d884d6 dag: node visits return diagnostics rather than errors
This allows node visits to also return warnings.
2018-10-16 18:44:26 -07:00
James Bardin 8cf0a8ca9c faster DAG transitive reduction
In the case of highly-connected graphs, the TransitiveReduction process
was far too computationally intensive. Since no operations are applied
to the nodes, and the walk order is not even user visible, we don't need
to sort them n^2 times.
2017-10-03 11:24:59 -04:00
James Bardin 1af7ee87a2 Silence log output when not verbose
Set the default log package output to iotuil.Discard during tests if the
`-v` flag isn't set. If we are verbose, then apply the filter according
to the TF_LOG env variable.
2016-08-01 17:19:14 -04:00
Paul Hinze b45f53eef4
dag: fix ReverseDepthFirstWalk when nodes remove themselves
The report in #7378 led us into a deep rabbit hole that turned out to
expose a bug in the graph walk implementation being used by the
`NoopTransformer`. The problem ended up being when two nodes in a single
dependency chain both reported `Noop() -> true` and needed to be
removed. This was breaking the walk and preventing the second node from
ever being visited.

Fixes #7378
2016-07-15 13:43:28 -06:00
Paul Hinze baa33d7326 core: dag errors should cascade to all descendents
We weren't marking skipped nodes as failing, so any
grandchild-and-deeper dependencies would still evaluate.

For example:

    A -> B -> C -> D

If B failed, C would be skipped, but D would still be evaluated.

This fixes the behavior so C, D, and any further descendents will all be
skipped when B fails.

Addresses crashing aspect of #2955 and likely a lot of other confusing
failure modes.
2015-08-07 11:38:58 -05:00
Paul Hinze 97acccd3ed core: targeted operations
Add `-target=resource` flag to core operations, allowing users to
target specific resources in their infrastructure. When `-target` is
used, the operation will only apply to that resource and its
dependencies.

The calculated dependencies are different depending on whether we're
running a normal operation or a `terraform destroy`.

Generally, "dependencies" refers to ancestors: resources falling
_before_ the target in the graph, because their changes are required to
accurately act on the target.

For destroys, "dependencies" are descendents: those resources which fall
_after_ the target. These resources depend on our target, which is going
to be destroyed, so they should also be destroyed.
2015-03-31 14:49:38 -05:00
Mitchell Hashimoto ed2075e384 dag: TransitiveReduction 2015-02-27 19:12:19 -08:00
Mitchell Hashimoto 54fd742ef6 dag: walk should be able to be halted 2015-02-19 12:07:57 -08:00
Mitchell Hashimoto 5b0004ffc7 dag: detect self references, use multierror 2015-02-19 12:07:56 -08:00
Mitchell Hashimoto e86698c50d dag: fix walk order issue, scc issues 2015-02-19 12:07:55 -08:00
Mitchell Hashimoto d59ced3c57 dag: Validate for DAGs 2015-02-19 12:07:55 -08:00
Mitchell Hashimoto e94c43e0dc dag: Walk 2015-02-19 12:07:55 -08:00
Mitchell Hashimoto cfa3d89265 dag: find root of AcyclicGraph 2015-02-19 12:07:55 -08:00