Commit Graph

1771 Commits

Author SHA1 Message Date
Mitchell Hashimoto c36b6c42ba
terraform: test case for #10982 (passes) 2017-02-13 13:06:22 -08:00
Mitchell Hashimoto 4d6085b46a
terraform: outputs should not be included if not targeted
Fixes #10911

Outputs that aren't targeted shouldn't be included in the graph.

This requires passing targets to the apply graph. This is unfortunate
but long term should be removable since I'd like to move output changes
to the diff as well.
2017-02-13 12:52:45 -08:00
James Bardin 92cea2478d Add test for nil *os.File in ReadState 2017-02-09 16:06:07 -05:00
James Bardin 0c1b138719 Add state locking during backend init
During backend initialization, especially during a migration, there is a
chance that an existing state could be overwritten.

Attempt to get a locks when writing the new state. It would be nice to
always have a lock when reading the states, but the recursive structure
of the Meta.Backend config functions makes that quite complex.
2017-02-09 15:47:27 -05:00
Mitchell Hashimoto 8ed9bdfedc
terraform: node referenceable name from state shuldn't contain path
Fixes #11749

I'm **really** surprised this didn't come up earlier.

When only the state is available for a node, the advertised
referenceable name (the name used for dependency connections) included
the module path. This module path is automatically prepended to the
name. This means that probably every non-root resource for state-only
operations (destroys) didn't order properly.

This fixes that by omitting the path properly.

Multiple tests added to verify both graph correctness as well as a
higher level context test.

Will backport to 0.8.x
2017-02-07 20:14:38 -08:00
Mitchell Hashimoto af61d566c2
terraform: passing test for destroy edge for module only
Just adding passing tests as a sanity check for a bug.
2017-02-07 19:12:03 -08:00
Mitchell Hashimoto ac3d67e40f
terraform: remove old logging line 2017-02-07 16:28:01 -08:00
Mitchell Hashimoto 7192c1a9a1 Merge pull request #11732 from hashicorp/b-diff-map-removal
terraform: ignore RequiresNew for collection removal in diff.Same
2017-02-07 12:58:15 -08:00
Mitchell Hashimoto e7aa1fd48d Merge pull request #11733 from hashicorp/b-disable-shadow
terraform: default shadow to false
2017-02-07 12:57:46 -08:00
Mitchell Hashimoto ac934cf003
terraform: add one more forgotten ordering assertion 2017-02-07 12:01:27 -08:00
Mitchell Hashimoto a765740827
terraform: CBD destroy nodes should not advertise themselves as normal 2017-02-07 11:49:50 -08:00
Mitchell Hashimoto 44233441c2
terraform: CBD edge should ignore "index" 2017-02-07 10:53:12 -08:00
Mitchell Hashimoto 864c79396d
terraform: default shadow to false
To avoid chasing down issues like #11635 I'm proposing we disable the
shadow graph for end users now that we have merged in all the new
graphs. I've kept it around and default-on for tests so that we can use
it to test new features as we build them. I think it'll still have value
going forward but I don't want to hold us for making it work 100% with
all of Terraform at all times.

I propose backporting this to 0-8-stable, too.
2017-02-06 18:02:32 -08:00
Mitchell Hashimoto fe32f7b189
terraform: ignore RequiresNew for collection removal in diff.Same
Fixes #11349

I tracked this bug back to the early 0.7 days so this has been around a
really long time. I wanted to confirm that this wasn't introduced by any
new graph changes and it appears to predate all of that. I couldn't find
a single 0.7.x release where this worked, and I didn't want to go back
to 0.6.x since it was pre-vendoring.

The test case shows the logic the best, but the basic idea is: for
collections that go to zero elements, the "RequiresNew" sameness check
should be ignored, since the new diff can choose to not have that at all
in the diff.
2017-02-06 17:46:48 -08:00
Mitchell Hashimoto ebb129f051
terraform: data source on refresh should just delete from state
This was caught by an acceptance test. We've now added a unit test. When
refreshing, an orphan (no config) data source should just be deleted.
2017-02-03 20:58:03 +01:00
Mitchell Hashimoto 1777f53a4b Merge pull request #11660 from hashicorp/f-graph-deps
terraform: remove ConnectDependents and related interfaces
2017-02-03 14:52:07 +01:00
Mitchell Hashimoto 755cef98b0
terraform: remove ConnectDependents and related interfaces 2017-02-03 14:25:54 +01:00
James Bardin 9acb86a182 Merge pull request #11187 from hashicorp/jbardin/state-locking
State Locking initial implementations
2017-02-01 14:35:55 -05:00
Mitchell Hashimoto 068b2b2dec
terraform: add Meta field to diffs
This adds a Meta field (similar to InstanceState.Meta) to InstanceDiff.

This allows providers to store arbitrary k/v data as part of a diff and
have it persist through to the Apply. This will be used by helper/schema
for timeout storage being done by @catsby.

The type here is `map[string]interface{}`. A couple notes:

  * **Not using `string`**: The Meta field of InstanceState is a string
    value. We've learned that forcing things to strings is bad. Let's
    just allow types.

  * **Primitives only**: Even though it is type `interface{}`, it must
    be able to cleanly pass the go-plugin RPC barrier as well as be
    encoded to a file as Gob. Given these constraints, the value must
    only comprise of primitive types and collections. No structs,
    functions, channels, etc.
2017-01-31 11:50:37 -08:00
James Bardin f20485550a Check for no state from the io.Reader
Read state would assume that having a reader meant there should be a
valid state. Check for an empty file and return ErrNoState to
differentiate a bad file from an empty one.
2017-01-30 17:16:57 -05:00
Mitchell Hashimoto 61881d2795 Merge pull request #10934 from hashicorp/f-provisioner-stop
core: stoppable provisioners, helper/schema for provisioners
2017-01-30 12:53:15 -08:00
Mitchell Hashimoto 3e771a674c
terraform: acquire stopCh outside goroutine to ensure in lock 2017-01-30 08:49:07 -08:00
Mitchell Hashimoto 195d34424e Merge pull request #11482 from hashicorp/f-computed-count
core: allow non-computed data source values in "count"
2017-01-30 08:44:27 -08:00
Mitchell Hashimoto 00232f0994
terraform: acquireRun during test to avoid special case logic 2017-01-30 08:41:38 -08:00
Mitchell Hashimoto 5b42781117
terraform: defer unlock of lock in Stop to enure it always unlocks 2017-01-30 08:35:10 -08:00
Mitchell Hashimoto 9183be4c83
update master version to 0.9.0-dev 2017-01-29 18:46:18 -08:00
Mitchell Hashimoto cf46e1c3e0
terraform: don't validate computed values in validate
This disables the computed value check for `count` during the validation
pass. This enables partial support for #3888 or #1497: as long as the
value is non-computed during the plan, complex values will work in
counts.

**Notably, this allows data source values to be present in counts!**

The "count" value can be disabled during validation safely because we
can treat it as if any field that uses `count.index` is computed for
validation. We then validate a single instance (as if `count = 1`) just
to make sure all required fields are set.
2017-01-27 21:15:43 -08:00
Mitchell Hashimoto 0ba3fcdc63
terraform: test static var being passed into grandchild for count 2017-01-27 20:38:07 -08:00
Mitchell Hashimoto 2162d6cf3d
terraform: test a basic static var count passed into a module 2017-01-27 20:32:55 -08:00
Mitchell Hashimoto dd6d025dbb
terraform: commmit generated file 2017-01-27 20:31:29 -08:00
Mitchell Hashimoto 2beb62c92b
terraform: remove flatten, forever 2017-01-26 21:03:27 -08:00
Mitchell Hashimoto 6d731b3b46
terraform: new provisioner node 2017-01-26 21:02:55 -08:00
Mitchell Hashimoto e89d738679
terraform: provider transform is converted to new graph world view 2017-01-26 20:58:22 -08:00
Mitchell Hashimoto 91c9c6032f
terraform: remove the old resource node 2017-01-26 20:48:05 -08:00
Mitchell Hashimoto d59725e9fd
terraform: convert StateDeps to use new structs 2017-01-26 20:47:20 -08:00
Mitchell Hashimoto c1e4bd7b72
terraform: remove graph config node file 2017-01-26 20:16:06 -08:00
Mitchell Hashimoto 348cfa0ed7
terraform: remove graph annotations 2017-01-26 20:13:42 -08:00
Mitchell Hashimoto a561934f61
terraform: keep pruning out lines 2017-01-26 20:12:01 -08:00
Mitchell Hashimoto 6c266d6ce3
terraform: prune down the resource node struct quite a bit 2017-01-26 20:08:55 -08:00
Mitchell Hashimoto a6bab455cc
terraform: remove node module file 2017-01-26 20:05:42 -08:00
Mitchell Hashimoto 37294d5ad2
terraform: remove old variable node 2017-01-26 20:04:39 -08:00
Mitchell Hashimoto 513ff88859
terraform: remove GraphConfigNodeType 2017-01-26 20:03:29 -08:00
Mitchell Hashimoto 31c813fa51
terraform: remove GraphNodeModule 2017-01-26 20:01:39 -08:00
Mitchell Hashimoto 3a97cf2df9
terraform: goodbye GraphNodeConfigProvider 2017-01-26 19:59:25 -08:00
Mitchell Hashimoto 0039f70d06
terraform: remove config transformer old 2017-01-26 19:57:46 -08:00
Mitchell Hashimoto 9086e996d6
terraform: convert all tests to use the new config transformer 2017-01-26 19:56:16 -08:00
Mitchell Hashimoto efc79d431e
terraform: more dead code removal 2017-01-26 19:47:02 -08:00
Mitchell Hashimoto 522a28ab95
terraform: convert root transform test to use new config transform 2017-01-26 19:40:46 -08:00
Mitchell Hashimoto 83e093a73e
terraform: delete destroy interfaces 2017-01-26 19:39:24 -08:00
Mitchell Hashimoto d820d186e1
terraform: remove old resource count transformer 2017-01-26 19:37:47 -08:00
Mitchell Hashimoto 4e4d51e6ba
terraform: remove old orphan transform 2017-01-26 19:36:02 -08:00
Mitchell Hashimoto 9426b71a5f
terraform: remove noop transformer 2017-01-26 19:32:49 -08:00
Mitchell Hashimoto e8eb0bd92f
terraform: delete proxy transformer 2017-01-26 19:31:32 -08:00
Mitchell Hashimoto ca0550e7eb
terraform: delete old module destroy transform 2017-01-26 19:30:27 -08:00
Mitchell Hashimoto 13e27c8b8f
terraform: delete old unused transforms 2017-01-26 19:29:15 -08:00
Mitchell Hashimoto 301cf60821
terraform: delete some flatten stuff 2017-01-26 18:10:07 -08:00
Mitchell Hashimoto 114315d502
terraform: delete legacy outputs 2017-01-26 18:09:07 -08:00
Mitchell Hashimoto be56ebf770
terraform: remove so much destroy transform 2017-01-26 18:00:47 -08:00
Mitchell Hashimoto b1b0e30f5a
terraform: remove old CBD transformer 2017-01-26 17:58:24 -08:00
Mitchell Hashimoto 09242fab09
terraform: remove legacy graph builder 2017-01-26 15:18:42 -08:00
Mitchell Hashimoto 83cc54bfbe
updated generate output 2017-01-26 15:11:47 -08:00
Mitchell Hashimoto a8f64cbcee
terraform: make sure Stop blocks until full completion 2017-01-26 15:10:30 -08:00
Mitchell Hashimoto 142df657c3
provisioners/remote-exec: listen to Stop 2017-01-26 15:10:30 -08:00
Mitchell Hashimoto f8c7b639c9
terraform: switch to Context for stop, Stoppable provisioners
This switches to the Go "context" package for cancellation and threads
the context through all the way to evaluation to allow behavior based on
stopping deep within graph execution.

This also adds the Stop API to provisioners so they can quickly exit
when stop is called.
2017-01-26 15:03:27 -08:00
Mitchell Hashimoto 523801dcc2
terraform: support backends in the state 2017-01-26 14:33:49 -08:00
Mitchell Hashimoto b35b263015 Merge pull request #11329 from hashicorp/f-destroy-prov
Destroy Provisioners
2017-01-26 14:32:21 -08:00
Mitchell Hashimoto 0b0114c9bf Merge pull request #11426 from hashicorp/f-new-graph
core: Refresh, Validate, Input on new graph builders
2017-01-26 14:31:03 -08:00
Radek Simko 0bafea87bb release: clean up after v0.8.5 2017-01-26 16:18:34 +00:00
Radek Simko b4d477660b
v0.8.5 2017-01-26 16:01:59 +00:00
Mitchell Hashimoto ae6bf241ec
terraform: validate self references 2017-01-25 21:00:45 -08:00
Mitchell Hashimoto 4a9cafcd67
terraform: expand count on resources during validation 2017-01-25 12:39:08 -08:00
Mitchell Hashimoto 86cbcff962
terraform: fixup a merge issue
We forgot to wrap some changes from the old branch into the new style
2017-01-25 12:32:09 -08:00
Mitchell Hashimoto 1427075005
terraform: wip moving validation to new graph 2017-01-25 12:28:07 -08:00
Mitchell Hashimoto 66f6f70cdb
terraform: input graph 2017-01-25 12:28:07 -08:00
Mitchell Hashimoto b2fb3b1d0f
terraform: import graph should setup parent refs to providers
Fixes #11212

The import graph builder was missing the transform to setup links to
parent providers, so provider inheritance didn't work properly. This
adds that.

This also removes the `PruneProviderTransform` since that has no value
in this graph since we'll never add an unused provider.
2017-01-24 15:36:45 -08:00
Mitchell Hashimoto 290ad37489
terraform: test case for #11282 2017-01-24 12:56:13 -08:00
Mitchell Hashimoto 7c014b84b6
terraform: handle count fields for data sources 2017-01-22 16:05:10 -08:00
Mitchell Hashimoto 38286fe491
terraform: Refresh supports new data sources 2017-01-22 13:00:01 -08:00
Mitchell Hashimoto 9c16489887
terraform: ConfigTransformer has Unique and mode filters 2017-01-22 12:58:18 -08:00
Mitchell Hashimoto d0b7a4a072
terraform: StateFilter handles cases where ResourceState has no type
This was possible with test fixtures but it is also conceiably possible
with older states or corrupted states. We can also extract the type from
the key so we do that now so that StateFilter is more robust.
2017-01-21 10:24:03 -08:00
Mitchell Hashimoto 2055885a0f
website: add destroy provisioners to getting started 2017-01-21 08:31:18 -08:00
Mitchell Hashimoto a50003d9f6
terraform: fix compilation by complying with interface 2017-01-20 20:45:06 -08:00
Mitchell Hashimoto d3df7874d5
terraform: introduce EvalApplyPre so that PreApply is called even for
destroy provisioners.
2017-01-20 20:36:53 -08:00
Mitchell Hashimoto f40fdde708
terraform: PostProvision hook gets the error from the provision step 2017-01-20 20:21:12 -08:00
Mitchell Hashimoto b56ee1a169
terraform: test on_failure with non-destroy provisioners 2017-01-20 20:05:28 -08:00
Mitchell Hashimoto 4a8c2d0958
terraform: on_failure for provisioners 2017-01-20 19:55:32 -08:00
Mitchell Hashimoto 85cb3a16b0
terraform: on destroy prov failure, don't taint and preserve state 2017-01-20 18:26:41 -08:00
Mitchell Hashimoto e9f6c9c429
terraform: run destroy provisioners on destroy 2017-01-20 18:07:51 -08:00
James Bardin 89259a1b00 Fix the removal of empty containers from a flatmap
Removal of empty nested containers from a flatmap would sometimes fail a
sanity check when removed in the wrong order. This would only fail
sometimes due to map iteration. There was also an off-by-one error in
the prefix check which could match the incorrect keys.
2017-01-20 16:23:10 -05:00
James Bardin 2820845f8c Remove 0 counts from flatmap during MergeDiff
When a InstanceState is merged with an InstanceDiff, any maps arrays or
sets that no longer exist are shown as empty with a count of 0. If these
are left in the flatmap structure, they will cause errors during
expansion because their existing in the map affects the counts for
parent structures.
2017-01-17 15:49:50 -05:00
clint f895f93769 release: clean up after v0.8.4 2017-01-11 17:21:31 +00:00
clint a791ff09b2
v0.8.4 2017-01-11 17:03:56 +00:00
stack72 288996f69c release: clean up after v0.8.3 2017-01-10 09:10:37 +00:00
stack72 b845cb7093
v0.8.3 2017-01-10 09:03:50 +00:00
Andrew Garrett 497010ce42 Fix string representation of sets during interpolation
The change in #10787 used flatmap.Expand to fix interpolation of nested
maps, but it broke interpolation of sets such that their elements were
not represented. For example, the expected string representation of a
splatted aws_network_interface.whatever.*.private_ips should be:

```
[{Variable (TypeList): [{Variable (TypeString): 10.41.17.25}]} {Variable (TypeList): [{Variable (TypeString): 10.41.22.236}]}]
```

But instead it became:

```
[{Variable (TypeList): [{Variable (TypeString): }]} {Variable (TypeList): [{Variable (TypeString): }]}]
```

This is because the expandArray function of expand.go treated arrays to
exclusively be lists, e.g. not sets. The old code used to match for
numeric keys, so it would work for sets, whereas expandArray just
assumed keys started at 0 and ascended incrementally. Remember that
sets' keys are numeric, but since they are hashes, they can be any
integer. The result of assuming that the keys start at 0 led to the
recursive call to flatmap.Expand not matching any keys of the set, and
returning nil, which is why the above example has nothing where the IP
addresses used to be.

So we bring back that matching behavior, but we move it to expandArray
instead. We've modified it to not reconstruct the data structures like
it used to when it was in the Interpolator, and to use the standard int
sorter rather than implementing a custom sorter since a custom one is no
longer necessary thanks to the use of flatmap.Expand.

Fixes #10908, and restores the viability of the workaround I posted in #8696.

Big thanks to @jszwedko for helping me with this fix. I was able to
diagnose the problem along, but couldn't fix it without his help.
2016-12-23 23:37:03 +00:00
Mitchell Hashimoto fc6e2a1b79 release: clean up after v0.8.2 2016-12-21 20:15:38 +00:00
Mitchell Hashimoto dd2c6da4f6
v0.8.2 2016-12-21 20:03:36 +00:00
James Bardin 084670c241 Use flatmap.Expand to extract interpolated values
Now that flatmap.Expand will properly expand nested maps, we can use
that to extract any lists and maps when interpolating.
2016-12-16 10:36:27 -05:00
James Bardin ec2550dea5 Sort interpolated lists by index
Interpolated lists should be sorted by index number, rather than
lexicographic key order.
2016-12-15 16:45:59 -05:00
James Bardin 61982be9c6 failing test with wrong interpolated list order
The plan diffs for aws_instance.a and aws_instance.b should be
identical.
2016-12-15 13:23:50 -05:00