Commit Graph

295 Commits

Author SHA1 Message Date
Mitchell Hashimoto
bcff7e070c terraform: don't prune, but disable, inherited configs [GH-1447] 2015-04-09 08:48:08 -07:00
Mitchell Hashimoto
36520121b1 terraform: disable providers that are only used by modules 2015-04-08 21:14:19 -07:00
Paul Hinze
816c4b475f core: [tests] fix order dependent test 2015-04-01 11:11:46 -05:00
Paul Hinze
c6300d511c core: formalize resource addressing
Only used in targets for now. The plan is to use this for interpolation
as well.

This allows us to target:

 * individual resources expanded by `count` using bracket / index notation.
 * deposed / tainted resources with an `InstanceType` field after name

Docs to follow.
2015-03-31 15:04:10 -05:00
Paul Hinze
40ebfb5ccc core: fill out context tests for targeted ops 2015-03-31 14:49:38 -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
a0839da71a terraform: merge provider configs before validate [GH-1282] 2015-03-25 16:28:52 -07:00
Mitchell Hashimoto
2dce764d75 terraform: add input mode to only ask for unset variables
This adds a new input mode for Context.Input() that will only ask for
variable values that are not set.
2015-03-24 13:30:21 -07:00
Paul Hinze
6c93fbb85d core: [refactor] store Deposed resource instances as a list
Deposed instances need to be stored as a list for certain pathological
cases where destroys fail for some reason (e.g. upstream API failure,
Terraform interrupted mid-run). Terraform needs to be able to remember
all Deposed nodes so that it can clean them up properly in subsequent
runs.

Deposed instances will now never touch the Tainted list - they're fully
managed from within their own list.

Added a "multiDepose" test case that walks through a scenario to
exercise this.
2015-03-04 12:25:59 -06:00
Mitchell Hashimoto
11d073f7d4 terraform: test the increase from one case 2015-03-01 21:39:48 -08:00
Mitchell Hashimoto
2389251c38 terraform: catch scenario where both "foo" and "foo.0" are in state 2015-03-01 21:28:41 -08:00
Mitchell Hashimoto
ac6efa5e57 Merge pull request #1065 from hashicorp/f-taint
Add "taint" command
2015-02-26 23:55:20 -08:00
Paul Hinze
c03e44106f core: band-aid fix for tainted double destroy
After a lot of fun debugging with @mitchellh we finally have a diagnosis
for #1056.

I'm going to attempt to reproduce the diagnosis in prose to test out my
understanding.

----

The `DestroyTransformer` runs twice:

 * `DestroyPrimary` mode creates destroy nodes for normal resources
 * `DestroyTainted` mode creates destroy nodes for tainted resources

These destroy nodes are specializations of `GraphConfigNode`, which has
a `DynamicExpand` step.

In `DynamicExpand` we have a race condition between the normal destroy
node and the tainted destroy node for a given resource when
`CreateBeforeDestroy` is off.

The `DestroyTainted` `GraphConfigNode` must run the `TaintedTransform`
to draw out tainted nodes, since it is reponsible for destroying them
for replacement.

The `DestroyPrimary` `GraphConfigNode` _also_ runs `TaintedTransform` -
this is to catch `Deposed` nodes from CBD, which are piggy backing on
the end of the `Tainted` list.

Here's the bug: when CBD is off and you start an apply with a tainted
resource in your state, both `DestroyPrimary` and `DestroyTainted` catch
it and create their own `graphNodeTaintedResource` in their respective
subgraphs.

If parallelism is disabled, this doesn't happen because the
`DestroyPrimary` subgraph resolves completely before the
`DestroyTainted` node does its `DynamicExpand`, so the `Tainted` list
has been cleared by the time `DestroyTainted` is expanding. With
parallelism, each of these two subgraphs plays out in its own goroutine
simultaneously, and each picks up the tainted resource(s) that the apply
starts with.  So you get two `graphNodeTaintedResource` nodes, and two
destroys.

This band-aid fixes that by skipping the TaintedTransform alltogether in
the `DestroyPrimary` node if CBD is off.

A better fix will follow, which involves reworking the `Deposed` concept
so it no longer piggybacks on `Tainted`.

fixes #1056
2015-02-26 22:32:50 -06:00
Mitchell Hashimoto
341be226f4 terraform: test for various taint cases 2015-02-26 09:50:18 -08:00
Mitchell Hashimoto
ac167c3082 terraform: test post state update is called 2015-02-23 22:10:31 -08:00
Mitchell Hashimoto
dd7bc5db0c terraform: more self tests 2015-02-23 15:02:26 -08:00
Mitchell Hashimoto
0e59acc2c9 terraform: enable self vars 2015-02-23 14:56:02 -08:00
Mitchell Hashimoto
022967acdb terraform: module inputs/vars can be non-strings [GH-819] 2015-02-23 13:50:53 -08:00
Mitchell Hashimoto
40ee70d5c9 terraform: Input should only be called on providers once
/cc @sethvargo

Prior to this commit, we'd only persist the result of calling Input if
any input was given (len(result) > 0). The result was that every module
would also repeat asking for input even if there was no input to be
asked for.

This commit makes it so that if no input was received, we still set a
sentinel so that modules don't re-ask.
2015-02-20 15:35:57 -08:00
Mitchell Hashimoto
ab414de0ab terraform: test case for destroying with a count [GH-527] 2015-02-20 10:02:52 -08:00
Mitchell Hashimoto
4b6f258f1f terraform: only depose state if we're doing the destroy side 2015-02-19 12:08:34 -08:00
Mitchell Hashimoto
10e96ad72d terraform: provisioner config is properly interpolated 2015-02-19 12:08:33 -08:00
Mitchell Hashimoto
459ad04d71 terraform: provider cache should append the provider name to it 2015-02-19 12:08:33 -08:00
Mitchell Hashimoto
7ccba588ac terraform: gofmt -w -r 'Context2 -> Context' terraform/ 2015-02-19 12:08:32 -08:00
Mitchell Hashimoto
e37c187228 terraform: goodbye context.go (old) 2015-02-19 12:08:32 -08:00
Mitchell Hashimoto
14b5942453 terraform: all input tests pass 2015-02-19 12:08:08 -08:00
Mitchell Hashimoto
7c78a3749e terraform: provider input 2015-02-19 12:08:08 -08:00
Mitchell Hashimoto
f3714f1efc terraform: start Input 2015-02-19 12:08:08 -08:00
Mitchell Hashimoto
960ba73f1d terraform: last apply test 2015-02-19 12:08:08 -08:00
Mitchell Hashimoto
1c713878b0 terraform: fix outputs on destroy 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
bd0c3b12cb terraform: more tests passing 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
c8091aa338 terraform: fix more create-before-destroy state juggling 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
33cad6d207 terraform: fix create before destroy edge case with partial state 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
f7f1f17b49 terraform: create before destroy 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
119d5a09cf terraform: fix some diff comparison 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
5f8d1b86d5 terraform: more passing tests 2015-02-19 12:08:07 -08:00
Mitchell Hashimoto
6bb3cb8f2f terraform: a lot more passing tests 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
742b45886a terraform: destroy nodes work properly 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
c3df003624 terraform: more passing tests 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
e2abf17c9c terraform: provisioners should only be run on first create 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
c70cc682ea terraform: resource provisioner self references are not put in the graph 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
edfb11ff1d terraform: more passing tests 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
79746cb35d terraform: state must not be nil for apply 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
819aed67d4 terraform: provisioners 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
f8871917f5 terraform: update tests 2015-02-19 12:08:06 -08:00
Mitchell Hashimoto
10e82375f2 terraform: early exit and cancellation 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
d0c77d268a terraform: more tests passing 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
843cfbe8ad terraform: tainted apply 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
a3e4b3e966 terraform: more apply tests 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
691db58478 terraform: apply for orphans 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
abc68a89a8 terraform: use the proper diff for apply time 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
aea6b0a7e1 terraform: compare bad diffs for apply 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
d72ceb597d terraform: more tests 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
9b7d1509fc terraform: outputs in apply 2015-02-19 12:08:05 -08:00
Mitchell Hashimoto
a614f6105a terraform: apply starting 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
93f3050dbd terraform: make things more linear 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
67e7aeeea0 terraform: PLAN IS DONE
http://i.imgur.com/fiw5hXx.gif
2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
f85baf6e26 terraform: more tests 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
ef32656a65 terraform: set the diff up properly with tainted resources 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
e82affdf5c terraform: more plan tests 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
ec6ce69e90 terraform: destroy module plan 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
e185769271 terraform: plan destroy 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
00f4245572 terraform: count increase from one tests 2015-02-19 12:08:04 -08:00
Mitchell Hashimoto
4ccb12508a terraform: decreasing counts works 2015-02-19 12:08:03 -08:00
Mitchell Hashimoto
4caab6870b terraform: more passing plan tests 2015-02-19 12:08:03 -08:00
Mitchell Hashimoto
354a35afb0 terraform: properly interpolate variable counts 2015-02-19 12:08:03 -08:00
Mitchell Hashimoto
4c3ea016b9 terraform: non-multi count resource is still index 0 2015-02-19 12:08:03 -08:00
Mitchell Hashimoto
14aee00bf0 terraform: setup proper count.index value for interpolation 2015-02-19 12:08:03 -08:00
Mitchell Hashimoto
8365d39d26 terraform: fix more plan tests 2015-02-19 12:08:03 -08:00
Mitchell Hashimoto
a2d278b284 terraform: more passing tests 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
10a216d85e terraform: nil diffs should not be written to the diff 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
32e714c41d terraform: computed outputs 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
de6827b3ed terraform: calculate outputs and store it into the state 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
fb3a67a6d7 terraform: more passing plan tests 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
4089d33dea terraform: provider merging should be parent OVER child 2015-02-19 12:08:02 -08:00
Mitchell Hashimoto
99eab4fd13 terraform: more passing plan tests 2015-02-19 12:08:01 -08:00
Mitchell Hashimoto
e45308fa6d terraform: module orphans are properly expanded and planned for destroy 2015-02-19 12:08:01 -08:00
Mitchell Hashimoto
f7bed9a2f9 terraform: more tests 2015-02-19 12:08:01 -08:00
Mitchell Hashimoto
10dee0dce8 terraform: more passing tests 2015-02-19 12:08:01 -08:00
Mitchell Hashimoto
23d097ee53 terraform: module inputs are passed through to subgraphs 2015-02-19 12:08:01 -08:00
Mitchell Hashimoto
5595229430 terraform: uncomments more passing tests 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
aae2d4c780 terraform: starting up the plans 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
a78fe784b8 terraform: REFRESH IS DONE
https://dl.dropboxusercontent.com/u/46819/gifs/america.gif
2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
2680b6bed4 terraform: refresh tainted resources 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
e5e4ac7548 terraform: deep copy the state when refreshing 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
cb80118674 terraform: so many tests passing 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
379c37dd06 terraform: refresh hooks 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
5ba52ceac4 terraform: another test 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
a616c362de terraform: more tests 2015-02-19 12:08:00 -08:00
Mitchell Hashimoto
863b9a4f45 terraform: filter eval nodes on operation 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto
d847b2b672 terraform: provider config inheritance in modules 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto
3db22d0de0 terraform: move more tests 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto
cf5f26bd9a terraform: walk static subgraphs 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto
220c2be571 terraform: convert more tests 2015-02-19 12:07:59 -08:00
Mitchell Hashimoto
d94c4392eb terraform: validate provisioners 2015-02-19 12:07:58 -08:00
Mitchell Hashimoto
31f6b7474d terraform: more tests 2015-02-19 12:07:58 -08:00
Mitchell Hashimoto
9cd877a59c terraform: validate resource names 2015-02-19 12:07:58 -08:00
Mitchell Hashimoto
8552bb18cf terraform: more tests 2015-02-19 12:07:58 -08:00
Mitchell Hashimoto
b8bc3dc19b terraform: provider should be cached by path 2015-02-19 12:07:58 -08:00
Mitchell Hashimoto
a41ec59510 terraform: move more tests 2015-02-19 12:07:58 -08:00